I am writing a vbscript component monitor which needs to run an external exe as a specific local user on the Orion server. So far I've found that although my credential for monitoring is set as that specific local user, my script, in fact, runs as the machine account instead. To test further I put together the following script to explicitly report the userids in use.
For the record, the machine name is copernicus, and the local user is copernicus\musr_mqadmin. The component credential is set to this userid. The test code is as follows and is executed passing ${USER} as the one and only argument.
Set lstArgs = WScript.Arguments
orion = trim(lstargs(0))
Wscript.Echo "Message.Orion:says I am " & orion
Wscript.Echo "Statistic.Orion:0"
set wshShell = createobject("wscript.shell")
Set wshEnv = wshShell.Environment("PROCESS")
Wscript.Echo "Message.Environment:says I am " & wshEnv("USERNAME")
Wscript.Echo "Statistic.Environment:0"
When I test run this script I get the following output...
Output Result:
Message.Orion:says I am copernicus\musr_mqadmin
Message.Environment:says I am COPERNICUS$
Statistic.Environment:0
Because the wshshell environment reports the wrong userid, my wshshell.exec in the real script fails to execute the command properly. So two questions, have I gone about this the right way, and am I right in assuming that the 'credential for monitoring' should be being used as the user the monitor is run as?
Note, I have not yet investigated the possibility of doing this successfully in powershell instead. I'm barely new to vbscript.
Thanks for any help.