mattolan
asked on
using runas to launch a cmd window from a vbs with unexpected result.
I am trying to create a vbs script that will launch a cmd window under an admin user account while a user is logged in. the problem I have is that when I combine the .Run command with the runas command I am getting strange results. my code is below. the strangeness is that no matter what I place after the runas the ouput is alwas /user:domain\administrator "notepad". I can type in complete junk like "lksjdjfo32445@345" and the output is still /user:domain\administrator "notepad".
could anyon tell me what is happening so I can correct this?
set WshShell = CreateObject("WScript.Shel l")
WshShell.Run "runas /user:domain\administrator cmd.exe", 9
could anyon tell me what is happening so I can correct this?
set WshShell = CreateObject("WScript.Shel
WshShell.Run "runas /user:domain\administrator
ASKER
still comes up as notepad
this worked for me...
wshShell.Run "cmd /k runas /user:domain\username notepad"
The /k states to leave the command window open after processing.../c closes it afterwards...
Not sure what you mean that it still comes up as notepad?
wshShell.Run "cmd /k runas /user:domain\username notepad"
The /k states to leave the command window open after processing.../c closes it afterwards...
Not sure what you mean that it still comes up as notepad?
can you post a screenshot?
www.ee-stuff.com is an upload site...
www.ee-stuff.com is an upload site...
ASKER
what I mean is that I enter
WshShell.Run "cmd /c runas /user:domain\administrator cmd.exe" in my vbs script but it outputs
runas /user\domain\administrator "notepad" instead.
it doesnot matter what I put after the runas portion of the command the results are always
/user\domain\administrator "notepad"
WshShell.Run "cmd /c runas /user:domain\administrator
runas /user\domain\administrator
it doesnot matter what I put after the runas portion of the command the results are always
/user\domain\administrator
Is your script named runas.vbs?
ASKER
this code
set WshShell = CreateObject("WScript.Shel l")
WshShell.Run "runas /user:domain\administrator cmd.exe", 9
or this code
set WshShell = CreateObject("WScript.Shel l")
WshShell.Run "runas asdfh4567$%^%&",9
will both generates this output
c:\>runas /user\domain\administrator "notepad"
Enter the password for domain\administrator:
set WshShell = CreateObject("WScript.Shel
WshShell.Run "runas /user:domain\administrator
or this code
set WshShell = CreateObject("WScript.Shel
WshShell.Run "runas asdfh4567$%^%&",9
will both generates this output
c:\>runas /user\domain\administrator
Enter the password for domain\administrator:
ASKER
my script is named test.vbs
ASKER
if I used the command from the cmd prompt it works, but as soon as I combine it with the WshShell.Run command it doesn't work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm thinking that's coming from somewhere else...
Even when I use your example and don't use cmd /c
the 'only' think I get at the prompt is to enter the password...
Even when I use your example and don't use cmd /c
the 'only' think I get at the prompt is to enter the password...
ASKER
that was it exactly I had an old file sitting on my destop called runas.bat.
I deleted it and the command works perfectly. glad you asked that question becuase I don't think I would have found that any time soon
I deleted it and the command works perfectly. glad you asked that question becuase I don't think I would have found that any time soon
Happy to help! :^)
WshShell.Run "cmd /c runas /user:domain\administrator