/build/static/layout/Breadcrumb_cap_w.png
06/19/2018 404 views
Hello!

I'm looking for help with a script that doesn't seem to be working for me.  The goal is to copy & replace an .exe on a workstation with a new version of that .exe I have saved as a dependency in KACE.  The script seems to end the processes but I can't figure out why the copy/replace isn't completing.  I've tried this as a batch file as well.  I have run this as the local SYSTEM user as well as with the local administrator credentials.

Here is essentially what I've got, though I've tried several variations:

The new .exe is set as a dependency

Task 1

Verify the directory exists
Verify the file exists
Verify process isn't running

On Success
Launch C:\Windows\System32\cmd.exe with params xcopy $(KACE_DEPENDENCY_DIR)\newfile.exe c:\Program Files\Existing Directory /q /y.

Remediation
Kill process

On Remediation Success
Launch C:\Windows\System32\cmd.exe with params xcopy $(KACE_DEPENDENCY_DIR)\newfile.exe c:\Program Files\Existing Directory /q /y.
Log "Success" to output

On Remediation Failure
Log "failure" to output
2 Comments   [ + ] Show comments

Comments

  • why don't you use Distribution|File Synchronization for that?
    • I looked into that but I'm not very familiar with how it works. I think I've set things up correctly, but how do I run that on a test machine to ensure it works?

      I only see a "schedule" I can set with hourly windows. Is there a way to push this out immediately?
      • for Scripts: use the Run Now
        for File Sync: force inventory (or run c:\program files (x86)\quest\kace\runkbot 6 0, that not a full inventory but only the file sync and MI is running)
  • Thanks Nico! One more question...I DID get it to work with File Sync, but what happens when the file is in use? Any idea how I should go about killing a process prior to running this file sync?

All Answers

0
When running cmd.exe to execute a command you need to specify the /c flag. This:
Launch C:\Windows\System32\cmd.exe with params xcopy $(KACE_DEPENDENCY_DIR)\newfile.exe c:\Program Files\Existing Directory /q /y

Should be:
Launch C:\Windows\System32\cmd.exe with params “/c xcopy "$(KACE_DEPENDENCY_DIR)\newfile.exe" "c:\Program Files\Existing Directory" /q /y

I think that your quotes for the xcopy command might have also been off. 
Answered 06/20/2018 by: chucksteel
Red Belt