Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

vbs script called from a service cannot execute certain commands

$
0
0

We have a service, running as domain admin user on Win Svr 2008 std ed, that must execute vb scripts.  The scripts execute, but calls to SETX.exe using Shell.Run fail to set environment variables.  However, SETX returns no errror msg. 

If I run the same script within a CMD window with elevated privilege (e.g. Administrator), the script works as expected and environment variables are set.

What is going on?  File creation fails as well.

The call looks like this:
gnReturnCode= RunCmd("setx.exe UD_UPGRADING_RELEASE "True" /m",True)

Where RunCmd is as follows:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function:  RunCmd( ByVal strCmd, ByVal bWait)
' desc: Execute a command string and wait for result if indicated
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function RunCmd( ByVal strCmd, ByVal bWait)
Dim nReturnCode, strWholeCmd
    nReturnCode= 0
    strWholeCmd= "%comspec% /c "&strCmd&" >"&gcsLogFile2
    nReturnCode= goShell.Run(strWholeCmd,0,bWait)
    WriteLog( "RunCmd("&strCmd&","&bWait&") returned "&nReturnCode)
    RunCmd= nReturnCode
EndFunction


Mark Maddox Sr. Tech Specialist

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>