Running a .bat file to install SNMP

(imported topic written by SystemAdmin)

I’m trying to run a .bat file to install SNMP on W2K3 servers. I am able to copy the files and change the registry settings to point to a file share to copy down needed files.

The relevance that I am using to run the bat file is

Runhidden “{pathname of system folder & “\cmd.exe”}” /Q /C cmd.exe /c “{pathname of parent folder of parent folder of system folder & “SNMP.bat”}”

It runs and completes but does not install SNMP

Any ideas?

(imported comment written by SystemAdmin)

It will probably just be a matter of formatting. The first thing I see is the last part of your relevance evaluates to:

q: pathname of parent folder of parent folder of system folder & “SNMP.BAT”

A: C:SNMP.BAT

T: 0.237 ms

I: singular string

It is missing the “/” after “C:”

So it should be:

q: pathname of parent folder of parent folder of system folder & “SNMP.BAT”

A: C:SNMP.BAT

T: 0.237 ms

I: singular string

The next thing you might try to do is capture the batch file to see if it will run locally. Add a line that copies the batch file locally so you can look in it and attempt to execute it.

Next thing I might do is see exactly how my my line is getting interpreted to make sure it can execute. For instance you might add the following line:

//capture the line to execute

appendfile “{pathname of system folder & “\cmd.exe”}” /Q /C cmd.exe /c “{pathname of parent folder of parent folder of system folder & “SNMP.bat”}”

move __appendfile “c:\temp.txt”

Now you can see how your relevance was interpreted in “c:\temp.txt”

Occasionally you will want to capture the sdout and stderr of a command. For instance:

wait cmd.exe somebatch.bat 1> output.text 2>&1

(imported comment written by SystemAdmin)

I don’t see how to edit a post so I will ammend my previous statement here. It should be:

q: pathname of parent folder of parent folder of system folder & “/SNMP.BAT”

A: C:/SNMP.BAT

T: 0.347 ms

I: singular string

(imported comment written by SystemAdmin)

Thanks - I tried your advice with a simpler command directly on the server and it works

cmd.exe /c c:\snmp.bat

however when I run it from an action script using waithidden or runhidden nothing happens

(imported comment written by SystemAdmin)

Did you try the other steps I suggested?

  1. have your action create a copy of your bat using “copy” to make sure the bat is valid.

2 have your action create a copy of the line you are trying to run using “appendfile”

  1. capture the stdout and stderr using 1> c:\logfile.txt 2>&1

Most likely there is just a syntax error in the evaluation of the relevance. So the above are some things I use to test them in an action.

Alternatively, you can use the Fixlet debugger on the action tab to test your action script.

(imported comment written by SystemAdmin)

Thanks I will try your steps - the relevance works with other bat files - just not with this one

(imported comment written by SystemAdmin)

You mention that you are trying to copy the files from a Share. You will need to ensure that it is an Anonymous Share. The Agent runs as Local System, and as such has no Network Identity of its own and putting credentials into an Action script is not advisable since the text of the Fixlet/task is stored on every computer with an agent subscribed to the site… You would be better to store the files on an http server and download them from there.