Jump to content

runas command , run a windows command as administrator with parameters


Recommended Posts

i need to run a program whilst a user is logged on who is not a local administartor.

I need to pass parameters to this program

EG : How can I run C:\Windows\System32\program.exe u  as local adminisatrator 

I need to compile the script as an .exe, note there are spaces in the above command also.

I have searched through help and looked at using cmdline but this doesnt work. If I run a program for example C:\Windows\System32\calc.exe with no arguments it runs fine but as soon as i want to pass argunments to the program it does not run

Many Thanks 

Edited by itye1970
Link to comment
Share on other sites

Welcome to the Autoit Forums :bye:

Can you post your script so that we may have a look?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Example()
 
Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "admin"
    Local $sPassword = "apassword"
 
 
 
   RunAs($sUserName, @ComputerName, $sPassword, 0, $iPID,  "C:\Windows\System32\bitlockerwizardelev.exe u", @SW_SHOWMAXIMIZED)
 
    
    WinWait("[CLASS:Notepad]", "", 10)
 
    ; Wait for 2 seconds.
    Sleep(20000)
 
 
    ;ProcessClose($iPID)
EndFunc   ;==>Example
Link to comment
Share on other sites

sorry is this one

Example()
 
Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "admin"
    Local $sPassword = "anypassword"
 
    
    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, "bitlockerwizard.elev u", "", @SW_SHOWMAXIMIZED)
 
    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)
 
    ; Wait for 2 seconds.
    Sleep(2000)
 
    
    ProcessClose($iPID)
EndFunc   ;==>Example
Link to comment
Share on other sites

  • Developers

try:

Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, 'bitlockerwizard.elev "\ u"', "", @SW_SHOWMAXIMIZED)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

:-( still no luck. If i go to windows command prompt and type in C:\Windows\System32\bitlockerwizardelev.exe u , it works fine but still not working with autoit

Example()
 
Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "123"
    Local $sPassword = "123"
 
    ; Run Notepad with the window maximized. Notepad is run under the user previously specified.
    ;Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, "calc.exe", "", @SW_SHOWMAXIMIZED)
Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, 'bitlockerwizard.elev " u"', "", @SW_SHOWMAXIMIZED)
    ; Wait 10 seconds for the Notepad window to appear.
    WinWait("[CLASS:Notepad]", "", 10)
 
    ; Wait for 2 seconds.
    Sleep(2000)
 
    ; Close the Notepad process using the PID returned by RunAs.
    ProcessClose($iPID)
EndFunc   ;==>Example
Link to comment
Share on other sites

Example()
 
Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "admin"
    Local $sPassword = "anypassword"
 
    
    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0,'bitlockerwizard.elev "\ u"', "", @SW_SHOWMAXIMIZED)
 
    sleep(2000)    

    ProcessClose($iPID)
EndFunc   ;==>Example

EDIT: Didn't see Jos' reply, this is the same thing :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

slow down, it seems you are throwing things at the problem, which will not help. Give a try to the script provided in my post #7 and tell us if it works or not :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Developers

 

:-( still no luck. If i go to windows command prompt and type in C:\Windows\System32\bitlockerwizardelev.exe u , it works fine but still not working with autoit

 

 

Why is the no space in this line in u and in your script you have a space?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Why is the no space in this line in u and in your script you have a space?

Jos

This could be why your script is not working :P

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

sorry its odd i know but it needs the space, the command from the windows prompt is

c:windowssystem32bitlockerwizardelev.exe u

Its the bitlocker reset password screen, for some reason microsoft decided to have a space in this command

the space needs to be there , otherwise it wont work.

Edited by itye1970
Link to comment
Share on other sites

Alright, so did you give the script provided in post #7 a try? If so, what were the results?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Developers

sorry its odd i know but it needs the space, the command from the windows prompt is

c:windowssystem32bitlockerwizardelev.exe u

Its the bitlocker reset password screen, for some reason microsoft decided to have a space in this command

the space needs to be there , otherwise it wont work.

Ok, then the next question: Why is the programname different in the script?

So you want:

Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, 'bitlockerwizardelev.exe "\ u"', "", @SW_SHOWMAXIMIZED)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Replace the line in your script with Jos' from post #13

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

did that but nothing appears

Example()
 
Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "username"
    Local $sPassword = "password"
 
 
    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, 'bitlockerwizardelev.exe " u"', "", @SW_SHOWMAXIMIZED)
 
    sleep(2000)
 
    ProcessClose($iPID)
EndFunc   ;==>Example
Link to comment
Share on other sites

  • Developers

Try this so the CMD window stays open and remove the Processclose()

Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, @comspec & ' /k bitlockerwizardelev.exe "\ u"', "", @SW_SHOWMAXIMIZED)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...