Executing a batch file on client through BigFix

(imported topic written by ryansmith91)

Apologies folks, I’m sure this is an easy one but having difficulty getting this to work correctly.

I’ve got a batch file that I’m using to remove software on some clients. I’ve packaged it through the Windows Software Deployment Wizard, which uploads the batch file to the server then downloads to the clients and executes. The batch file does its job perfectly when I run it on the client from the __Download folder. However, when I attempt to have it executed through BigFix it never runs (the action script does complete, but the batch file doesn’t appear to run as the software never uninstalls).

I’ve tried running as:

run __Download\remove.bat

dos __Download\remove.bat

wait __Download\remove.bat

…with no success. What am I missing here? Thanks in advance for assistance!

Ryan

(imported comment written by jessewk)

Ryan,

I think the run or wait command should work.

Is it possible that your script works in the current user context, but not when run as the system account or when no user is present?

(imported comment written by ryansmith91)

Hmmm…if so, then I’m out of luck. I’m trying to remove software from servers. I see that you can use the RunAsCurrentUser executable from: http://forum.bigfix.com/viewtopic.php?id=74, but as they are servers and shouldn’t have a current user for the most part, it won’t work. Ben / Tyler, ideas?

(imported comment written by brolly3391)

Ryan,

When I am having problems getting a bat file to work as an action, I usually translate what is going on in the bat file into action script. It makes it easier to see what is failing and where.

Can you edit your batch file to remove any potentially confidential information and post it here?

Cheers,

Brolly

(imported comment written by ryansmith91)

Sure…the batch file is very simple. It runs the application’s installer in silent mode, using an answer file accessed via a UNC share:

echo off

“C:\Program Files\InstallShield Installation information{DCD3461A-7AA6-44D3-9DC2-FE7B28DC7189}\setup.exe” -s -f1\\netlogon\patches\PolicySoftwareInstall\uninstall.iss

The action script used does the following:

Action1

download http://ourbigfixserver.com:<port#>/Uploads/599e3f86a0a798045459d54aa75f0c7309be6a8a/big1BF.tmp

continue if { (size of it = 219 and sha1 of it = “599e3f86a0a798045459d54aa75f0c7309be6a8a”) of file “big1BF.tmp” of folder “__Download”}

extract big1BF.tmp

run __Download\remove.bat

(imported comment written by jessewk)

I would convert this entirely to a BES action script. You’ll get much better performance, and I suspect the source of your issue is the inability to access the network share using the SYSTEM account. You could solve this by making your shares ‘null sessions shares’, but I think you’ll find it easier to just make an action script that does the whole thing.

You’ll need to get the .iss file onto the bes server. You can do this via the upload wizard, or by caching it manually in the wwwroot directory. If you use the upload wizard it has the nice effect of creating the ‘continue if’ statement for you with the correct size and sha1. Assuming you use the upload wizard, modify the generated action to execute your command. In the end it will look something like this:

download http:
//ourbigfixserver.com:<port#>/Uploads/sha1abcdefghijklmsha1/big1BF.tmp  

continue 

if 
{ (size of it = 219 and sha1 of it = 
"sha1abcdefghijklmsha1") of file 
"big1BF.tmp" of folder 
"__Download"
} extract big1BF.tmp   wait 
"C:\Program Files\InstallShield Installation information\{{DCD3461A-7AA6-44D3-9DC2-FE7B28DC7189}\setup.exe" -s -f1
"{pathname of client folder of current site}\__Download\uninstall.iss"

Note the double {{ . Curly braces are a reserved character in the action script to denote the start of a relevance expression. You need to escape the left brace by adding a second left brace so that the client will not try to interpert the GUID as a relevance expression.

1 Like

(imported comment written by ryansmith91)

That was the fix! Looks like I just needed to add the extra curly bracket, because I tried all the other possibilities for the command statement. I also made sure that the action downloaded the uninstall.iss file to the local __Download folder.

All good now…thanks for the responses!

-Ryan

1 Like