Runas Error when trying to run a .bat file as Admin

I

Irene

Hello,

I am getting an error when trying to run a vbscript that executes a
batch which installs a font.

Vbscript
Set objNetwork = Wscript.CreateObject("WScript.Network")

On Error Resume Next


Set WshShell = CreateObject("WScript.Shell")
strProgram = "N:\instFont.bat"

WshShell.Run "cmd.exe /k runas /env /user:[email protected] " & _
chr(34) & strProgram & chr(34)
Do Until Success = True
Success = WshShell.AppActivate("C:\WINDOWS")
Wscript.sleep 500
Loop
WshShell.SendKeys "XXXXXX"
WshShell.SendKeys "{ENTER}"


the error:

Attempting to start N:\instFont.bat as user "i
RUNAS ERROR: Unable to run - N:\instFont.bat
3: The system cannot find the path specified.


I am mapped to the N drive, i have tried using UNC, and i have tried
to copy the file to the C drive

Thanks,
Irene
 
S

Shenan Stanley

Irene said:
I am getting an error when trying to run a vbscript that executes a
batch which installs a font.

Vbscript
Set objNetwork = Wscript.CreateObject("WScript.Network")

On Error Resume Next


Set WshShell = CreateObject("WScript.Shell")
strProgram = "N:\instFont.bat"

WshShell.Run "cmd.exe /k runas /env /user:[email protected] " & _
chr(34) & strProgram & chr(34)
Do Until Success = True
Success = WshShell.AppActivate("C:\WINDOWS")
Wscript.sleep 500
Loop
WshShell.SendKeys "XXXXXX"
WshShell.SendKeys "{ENTER}"


the error:

Attempting to start N:\instFont.bat as user "i
RUNAS ERROR: Unable to run - N:\instFont.bat
3: The system cannot find the path specified.

I am mapped to the N drive, i have tried using UNC, and i have tried
to copy the file to the C drive

Yes - but when you RUNAS - all the mappings the local non-admin has are no
longer valid. You are not running under those credentials anymore - so that
user you are logged in as/running RUNAS with means squat - in other words,
the N drive they have mapped is not usable by the application you are
'RUNAS'ing.

In other words - you have no N when you execute the program as RUNAS - that
counts inside your batch script as well - which I would assume does not get
the font(s) from the local machine either. Both cannot have reference to a
network drive that the user you are runasing as does not have currently
mapped/in use/available to them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top