Sign in to follow this  
Followers 0
reapersdirge

help running elevated vbs

6 posts in this topic

hi everyone, i am having trouble executing a very basic run as.

Local $sUserName = "myusername"
Local $sDomain = "mydomain"
Local $sPassword = "mypassword"
Local $sProgram = "wscript.exe|c:\users\user\desktop\working.vbs"
;Local $sWorkingdir = ""

RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram, $sWorkingdir @TempDir)

i know the vbs is fine as i can execute it and it does what it should, i just cannot get the run as elevated part to work and im a little unsure a bout the pipe too.

thank you to anyone with an idea on this one.

Share this post


Link to post
Share on other sites



The parameter after $sProgram isn't formatted correctly. You have your working directory and your @TempDir in the same parameter with just a space between them. Not sure what you were wanting in that spot, but that's not going to work.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Sorry you were right last one was a bit of a mess ho wabout this. once i clean up the working dir. and put a space either side of the pipe i get a

there is no file extension in "c:\users\user\desktop\|" error

which i thought was windows not being set to run wscript by default in the registry. i did check hkey_classes_root\vbsfile\shell\open\command.

the annoying thing is i can get this running fine with shell execute or run or runwait

Local $sUserName = "myusername"
Local $sDomain = "mydomain"
Local $sPassword = "mypassword"
Local $sProgram = "wscript.exe | c:\users\user\desktop\working.vbs"
Local $sWorkingdir = "C:\users\user\desktop\"

RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram, $sWorkingdir)

Share this post


Link to post
Share on other sites

Why are you piping the vbs script ot wscript instead of just running the script with wscript? What the pipe does is send the output of wscript.exe to the working.vbs script, which is probably not what you want.

Local $sUserName = "myusername"
Local $sDomain = "mydomain"
Local $sPassword = "mypassword"
Local $sProgram = "wscript.exe c:\users\user\desktop\working.vbs" ; <<<<<<<<<< no pipe character
Local $sWorkingdir = "C:\users\user\desktop\"

RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram, $sWorkingdir)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

seems like you've nailed it. fresh pair of eyes always help.

thank you very much

Share this post


Link to post
Share on other sites

You're welcome, they should all be as quick to get fixed. :)


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0