d_glenn
asked on
What user does WSCRIPT.Shell run as?
If I use the WSCRIPT.Shell's "run" method to execute a command line program, what user does this run as?
I am able to get my program to run, however it uses some COM components which need to be ran as a specific user. I have tried changing the IIS Directory Security permissions to the user I want it to run as, but this does not seem to work.
Any ideas?
Thanks in advance.
David
I am able to get my program to run, however it uses some COM components which need to be ran as a specific user. I have tried changing the IIS Directory Security permissions to the user I want it to run as, but this does not seem to work.
Any ideas?
Thanks in advance.
David
Does IUSR_{yourservername} user has rights to execute those COM componets ? Check that and assign permission to that user to those COM componets and then try runnign as This user from IIS
it runs as IUSR_*, unless you turn off anonymous access to your virtual directory and login as the desired user.
ASKER
I have already changed it so that anonymous access for the virtual directory uses my user with the appropriate DCOM permissions.
Any other ideas?
Thanks
Any other ideas?
Thanks
I have to disagree here.
IUSR_machine is for ASP, not WScript. I even tested it to make sure.
VB EXE (who.exe)
------------
dim oSys as Nnew WinNTSysInfo
msgbox oSys.UserName
VB Scirpt
-------------
Set Wsh = WScript.CreateObject("WScr ipt.Shell" )
Wsh.Run "who.exe"
Result: Currently Logged On User.
WSCript RUN runs in context of currently logged on user.
IUSR_machine is for ASP, not WScript. I even tested it to make sure.
VB EXE (who.exe)
------------
dim oSys as Nnew WinNTSysInfo
msgbox oSys.UserName
VB Scirpt
-------------
Set Wsh = WScript.CreateObject("WScr
Wsh.Run "who.exe"
Result: Currently Logged On User.
WSCript RUN runs in context of currently logged on user.
ASKER
...but I am running the WSCRIPT.Shell component in an ASP page, so there is not a user to be logged in as.
ASKER
Shouldn't it run as the user specified in the "Account used for anonymous access" in IIS for the virtual directory?
I see. I didn't realize you were running from the ASP page.
I actually have a piece of code that will spawn RunAs from VB with alternate credentials to move the current user from group to group. Here's a piece that you might find useful:
sRunAsCmd = "C:\Winnt\System32\RunAs.e xe"
sRunAsParams = " /user:DOMAIN\USRNAME "
sApp = "\" & Chr(34) & App.Path & "\YourApp.exe\" & Chr(34) & " "
sParams = "\" & Chr(34) & "Your Parameters" & "\" & Chr(34)
sCommand = sRunAsCmd & sRunAsParams & Chr(34) & sApp & sParams & Chr(34)
Set oShell = New IWshShell_Class
vTaskID = Shell(sCommand, 1)
DoEvents
Sleep 400
If oShell.AppActivate(vTaskID ) Then
oShell.SendKeys sPwd & "{ENTER}"
End If
I actually have a piece of code that will spawn RunAs from VB with alternate credentials to move the current user from group to group. Here's a piece that you might find useful:
sRunAsCmd = "C:\Winnt\System32\RunAs.e
sRunAsParams = " /user:DOMAIN\USRNAME "
sApp = "\" & Chr(34) & App.Path & "\YourApp.exe\" & Chr(34) & " "
sParams = "\" & Chr(34) & "Your Parameters" & "\" & Chr(34)
sCommand = sRunAsCmd & sRunAsParams & Chr(34) & sApp & sParams & Chr(34)
Set oShell = New IWshShell_Class
vTaskID = Shell(sCommand, 1)
DoEvents
Sleep 400
If oShell.AppActivate(vTaskID
oShell.SendKeys sPwd & "{ENTER}"
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.