Kaseya Community

Can't write file

  • I'm getting a strange error when trying to write two files via script to a Windows 7 agent. The script is simple:


    Script Name: FileAssassin
    Script Description: Transfer FileASSASSIN to the agent and run silently from the command line to delete a file on reboot.

    NOTE: Must specify the file to be deleted in Step 3 PRIOR to running.

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\FileASSASSIN.dll
    Parameter 2 : VSASharedFiles\FileASSASSIN.dll
    OS Type : 0
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\FileASSASSIN.exe
    Parameter 2 : VSASharedFiles\FileASSASSIN.exe
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #vAgentConfiguration.agentTempDir#\FileASSASSIN.exe /onreboot /silent "C:\Program Files\PersonalSec\psecurity.exe"
    Parameter 2 : 1
    OS Type : 0
    ELSE


    I get this error on both the .dll and the .exe:

    FAILED in processing THEN step 1, Write File, with error File Open Failed, Source = C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles\FileASSASSIN.dll, Destination = c:\temp\FileASSASSIN.dll

    I'm wondering if anyone else has seen this? I have many other scripts, custom and stock, that write files to the temp directory just fine. Yes, the files exist in the appropriate spot on the kserver.

    Legacy Forum Name: Can't write file,
    Legacy Posted By Username: mastermindpro
  • Make sure your agent temp dir (#vAgentConfiguration.agentTempDir#) is not C:\temp

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: thirteentwenty
  • That is the agent temp directory. Why can it not be that?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mastermindpro
  • mastermindpro
    That is the agent temp directory. Why can it not be that?


    Scores of reasons, one of which not everything is allowed to write files there, and a bigger one is that important things can be removed from there... there are a few threads in the General Discussion area that address this.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: thirteentwenty
  • OK, seems pretty stupid for that to be the default location, then. You still haven't explained why lots of scripts can write here but this one can't.

    Just for kicks and grins, I modified the temp directory to c:\mgmttmp on the system I was testing and moved the contents of the old temp dir to the new one. The above script still fails:

    FAILED in processing THEN step 1, Write File, with error File Open Failed, Source = C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles\FileASSASSIN.dll, Destination = c:\mgmttmp\FileASSASSIN.dll

    I guess I have to open a ticket...ugh.

    BTW, I have NO idea why this forum is displaying a space between the "l" and the "e" in the source file name. It's not present when I'm editing this message???

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mastermindpro
  • mastermindpro
    FAILED in processing THEN step 1, Write File, with error File Open Failed, Source = C:\Kaseya\WebPages\ManagedFiles\VSASharedFiles\FileASSASSIN.dll, Destination = c:\mgmttmp\FileASSASSIN.dll

    BTW, I have NO idea why this forum is displaying a space between the "l" and the "e" in the source file name. It's not present when I'm editing this message???


    The reason for the added space is a limitation in how long a string of text can be without any spaces in it. You will see this many times when users copy/paste code into the forum without using the CODE tags. Just a minor pain.

    One thought to your main problem may be the files themselves. Could they be detected by an antivirus/antimalware program that is blocking them from being written? Try changing the files to *.DL0 (that's a zero) and *.EX0 (again, zero) and see if you can upload them. Then, try running a rename command to put them right. That may help with the troubleshooting.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: CCDave
  • Opened a ticket...no word on the fix. I think it may be an incompatibility with Win7, but I'm not sure. I have multiple scripts trying to copy different files to the temp dir, but only small sections of the file are being transferred before erroring out.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mastermindpro
  • I just experienced the same thing. I have several dozen new Win7 machines that need my Adobe Reader script run on them, all fail with the same error you've seen

    Have you heard anything back from support?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JMF
  • Nothing but excuses.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mastermindpro
  • So is it .dll files or all types of files?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: diggrp
  • In my case, I was trying to write the Adobe Reader installer .exe file.

    I'd submit a ticket, but I already know the answer Roll Eyes

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JMF
  • I got the same errors when trying to write exe or dll files. I didn't try anything else, as most of what we want to write to the agent temp directory is an executable of some sort.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mastermindpro
  • Are you sure it's not your anti-virus software not liking the file?

    I have the following:

    ELSE
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\bitsadmin.exe
    Parameter 2 : VSASharedFiles\bitsadmin.exe
    OS Type : 0
    Execute Script

    And it does the job every time...

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Lmhansen
  • I thought that was the case as well, so I uninstalled the AV software (KES..har, har) and rebooted. It didn't solve the problem at the time. The problem has come and gone on some agents, so I suspect hotfixes creating and then fixing the problem.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: mastermindpro
  • Have you tried "use credential" in the script? Have you tested that the Agent credentials are good?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Lmhansen