Running a DOS Batch File through Bigfix Custom Action

(imported topic written by swalsh1991)

Hi All,

First off I hope this question qualifies for this section of the forum. If it doesn’t I apologize.

I’m a newb to bigfix and require some assistance. I’m trying to execute a simple dos batch file via the Bigfix Custom Action Script but have no idea how to write the bigfix script.

Could I be shown an example script using the filename testscript.bat, which would be at the root of C: on the bigfix server.

(imported comment written by gjeremia91)

A trivial example below, but ensure you read the fixlet authoring information on the bigfix support website

// Remove any prior attempts

delete __appendfile

delete mybatch.bat

// Create the batch file

appendfile @ECHO OFF

appendfile @dir “{pathname of system folder}” > c:\test.txt

// batch file was created as __appendfile

// move it to a batch file name

move __appendfile mybatch.bat

// now run it

run mybatch.bat

(imported comment written by gjeremia91)

If the batch file already exists, lets say in the windows folder, you just need to run it:

// fail if we can’t find the file

continue if {exists file “runme.bat” of windows folder}

// otherwise run it

run “{pathname of windows folder}\runme.bat”

(imported comment written by swalsh1991)

Thanks. So all I need to do then to execute a batch file then if it exists at the root of a drive is:

run d:\batchfilename.bat

That seems way too easy!

(imported comment written by gjeremia91)

yes, I’ll make sure I put in the feature request to make that one harder, lol

you can choose from:

run

runhidden

wait

waithidden

Be careful with the referencing of absolute paths. Nothing wrong with those, but sometimes using references to bigfix inspectors can support a more dynamic environment.

(imported comment written by SY57_Jim_Montgomery)

I don’t think you can just run a batch file in windows. You need to use cmd to interpret it. Keep in mind the folder that actions run in.

download http://blah/sample.bat

run “{pathname of system folder}\cmd.exe /c __download\sample.bat”

(imported comment written by NoahSalzman)

Actually, you can. The Actionscript

run “c:\foo.bat”

will work. Of course, I’m doing this on Vista at the moment. Perhaps there earlier Windows versions that don’t support that?

(imported comment written by SY57_Jim_Montgomery)

Yeah, I take it back. Running batch files is just fine.