Replacing a file or task!

(imported topic written by ajnleson72891)

Need a bit of assistance.

I have previously pushed out a task located in C:\WINDOWS\Task\delete-event-logs.job, this task has incorrect information in it. I want to delete this job and replace it with a new task, maybe even with the same name. I’ve tried several attempts but it cant seem to get it down, it keeps failing.

Any help will be great…

Thanks.

Anthony

(imported comment written by jessewk)

can you post the action script and relevance for your task, please?

(imported comment written by ajnleson72891)

Relevance 1

(

name of operating system = “WinNT”

OR

name of operating system = “Win2000”

OR

name of operating system = “Win2003”

)

AND

TRUE

(name of operating system = “WinNT” OR name of operating system = “Win2000” OR name of operating system = “Win2003”) AND TRUE

Actions

Action1 (default)

Script Type BigFix Action Script

delete “%windir%\Tasks\delete-events-logs.job”

Action2

Script Type BigFix Action Script

download http://hqbes01:52311/Uploads/b255e72721e53474df73bf7ae5ea9654ae92a135/bigF0.tmp

continue if { (size of it = 227 and sha1 of it = “b255e72721e53474df73bf7ae5ea9654ae92a135”) of file “bigF0.tmp” of folder “__Download”}

extract bigF0.tmp

move __Download\delete-event-logs.job "%windir%\Tasks\delete-event-logs.job

(imported comment written by jessewk)

Hi Anthony,

The % character is used for character encoding, so if you need to use a percent in action script you have to encode it as %25. Also, environment variables are not expanded in action script unless you use relevance substitution.

Here’s how I would rewrite your 2 actions as a single action:

download http://hqbes01:52311/Uploads/b255e72721e53474df73bf7ae5ea9654ae92a135/bigF0.tmp
continue if { (size of it = 227 and sha1 of it = “b255e72721e53474df73bf7ae5ea9654ae92a135”) of file “bigF0.tmp” of folder “__Download”}
extract bigF0.tmp
delete "{pathname of windows folder}\Tasks\delete-events-logs.job"
move __Download\delete-event-logs.job "{pathname of windows folder}\Tasks\delete-event-logs.job

2 things of interest there:

  • I replaced %windir% with {pathname of windows folder}. This uses our built in inspectors instead of environment strings.

  • I moved the download to the top. This doesn’t really matter because all actions are parsed for downloads before running and they are performed prior to the action running, so even if the download is listed at the bottom of the script it will actually happen at the beginning.

Finally, if you did want to stick with environment variables (I wouldn’t recommend this because it’s more fragile) you can use this syntax:

download http://hqbes01:52311/Uploads/b255e72721e53474df73bf7ae5ea9654ae92a135/bigF0.tmp
continue if { (size of it = 227 and sha1 of it = “b255e72721e53474df73bf7ae5ea9654ae92a135”) of file “bigF0.tmp” of folder “__Download”}
extract bigF0.tmp
delete "{expand environment string of “%25windir%25”}\Tasks\delete-events-logs.job"
move __Download\delete-event-logs.job "{expand environment string of “%25windir%25”}\Tasks\delete-event-logs.job

Jesse