Copy downloaded file to location on target PC

(imported topic written by flayofish91)

Guessing this will be an easy one for you guys:

Published a download on an internal website that contains some updated tools for our PC support teams.

The files are in a self-extracting .exe that will extract to whatever folder you run it from.

What I’d like to do is, delete the existing subfolder structure, download the self-extracting .exe, copy the .exe to the proper parent folder on the target PC, run the .exe, then delete the .exe when completed.

exapmle:

Target PC:

  1. agent deletes existing c:\windows\pctools*.*

  2. downloads self extracting .exe from internal website

  3. copies .exe to c:\windows\pctools\

  4. runs .exe from c:\windows\pctools

  5. deletes .exe when completed.

-thanks!

(imported comment written by flayofish91)

Changed the .exe to self-extract to desired location.

Just curiuos about one part. To remove the unwanted folder and its subfolders, would the action part be:

dos rmdir “C:\Windows\parentfolder\targetfolder” /f /q

-thanks!

(imported comment written by flayofish91)

Figured it out.

Complete action:

waithidden cmd /c rd /q /s “C:\WINDOWS\parentfolder\targetfolder”

download http://pcutilupdate:8080/files/tools.exe

continue if {(sha1 of it = “sha-1 code”) of file “tools.exe” of folder “__Download”}

waithidden __Download\tools.exe /quiet /norestart

waithidden cmd /c del /f /q “C:\Program Files\BigFix Enterprise\BES Client__BESData\actionsite__Download\tools.exe”

Feel free to delete this post, unless you guys think others may find value in it.

-thanks

(imported comment written by JackCoates91)

looks good. You could shorten it by a line if you use prefetch instead of download and continue if. You could also just wait for cache management to clear the downloaded tools.exe, but I presume you have a good reason for wanting it deleted ASAP.

(imported comment written by flayofish91)

Thanks for the prefetch tip!