Sign in to follow this  
Followers 0
akorx

Runas with vbs - need help

3 posts in this topic

#1 ·  Posted (edited)

Hi guys !

I often use the "runas" command on my lan to load processes with admin rights... but now i've got a problem, i want to run a vbs script and i can't.

Here is my autoit script :

Local $Application = "C:\WINDOWS\system32\wscript.exe"

Local $Command = "$Application" & " " & $CmdLineRaw

RunAs("administrateur",@ComputerName,"beeeeeep",0,$Command)

=> it doesn't work... but if i put RunAs("administrateur",@ComputerName,"beeeeeep",0,"C:\WINDOWS\system32\wscript.exe my_script.vbs") it works !!!

So why ? where is the error ?

At the end i want to run my program like this : powerscript.exe "my_script.vbs" and it's the reason why i don't use my solution...

Sorry for my bad english, i'm french :) .

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi akorx

you have accidentally posted in wrong forum a mod should move for you shortly... :)

This thread needs to be moved.

Hi guys !

I often use the "runas" command on my lan to load processes with admin rights... but now i've got a problem, i want to run a vbs script and i can't.

Here is my autoit script :

Local $Application = "C:\WINDOWS\system32\wscript.exe"

Local $Command = "$Application" & " " & $CmdLineRaw

RunAs("administrateur",@ComputerName,"beeeeeep",0,$Command)

=> it doesn't work... but if i put RunAs("administrateur",@ComputerName,"beeeeeep",0,"C:\WINDOWS\system32\wscript.exe my_script.vbs") it works !!!

So why ? where is the error ?

At the end i want to run my program like this : powerscript.exe "my_script.vbs" and it's the reason why i don't use my solution...

Sorry for my bad english, i'm french ;) .

so RunAs("administrateur",@ComputerName,"beeeeeep",0,"C:\WINDOWS\system32\wscript.exe my_script.vbs") actually works?

I think your variables may need adjusting and you have not defined your vbs script anywhere from what i could see.

Old

Local $Application = "C:\WINDOWS\system32\wscript.exe" 
Local $Command = "$Application" & " " & $CmdLineRaw 
RunAs("administrateur",@ComputerName,"beeeeeep",0,$Command)

new

$domain = @ComputerName
$usr = 'Administrator'
$pwd = 'beeeeeep'
$myscript = "nerve-login.vbs"

$Application = 'C:\WINDOWS\system32\wscript.exe'
$Command = $Application & " " & $myscript

RunAs($usr, $domain, $pwd, 0, $Command, @SystemDir, @SW_SHOW)

let me know how it goes for you

ftc

Edited by failedtocompile

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You shouldn't have quotes around $Application because you want the contents of that variable, not the literal name of the variable.

Local $Command = $Application & " " & $CmdLineRaw

But, you don't want $CmdLineRaw either. That is a reserved AutoIt variable and does not contain the "my_script.vbs" command line argument (it contains the entire line instead). What you meant was more like this:

Local $Application = "C:\WINDOWS\system32\wscript.exe" 
Local $Command = $Application & " "
If $CmdLine[0] Then 
    $Command &= $CmdLine[1]
    RunAs("administrateur", @ComputerName, "beeeeeep", 0, $Command)
Else
    MsgBox(16, "Error", "Missing command line parameter.")
EndIf

Note that command line arguments are in the $CmdLine array, and element $CmdLine[0] contains the count. See the help file under "Command Line Parameters".

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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