Jump to content

Executing EXE in Elevated Previllage


Recommended Posts

 

I am trying to execute a exe file in auto it as elevated previlage , but not successful till now . below are the methods i tried till now.

Disabled UAC access from windows and  selected run only as administrator from executable properties.  i logged in as administrator but still exe needs to launch as run as administrator.

 

Used Below methods from forum still no luck. anything i missing? i tried to use powershell.ps1 intead of exe as well.

1.  Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "c:\Exec.exe", "", @SW_SHOWMAXIMIZED)

2.  RunWait("C:\Automation\TestScripts\Writefilter.exe", @WindowsDir, @SW_MAXIMIZE)     - Std out error

 

Quote

If IsAdmin() Then MsgBox($MB_SYSTEMMODAL, "", "The script is running with admin rights.") 

This command gives out put as running with admin rights

#include <MsgBoxConstants.au3>
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#RequireAdmin

Example()

Func Example()
    ; Change the username and password to the appropriate values for your system.
    Local $sUserName = "Admin"
    Local $sPassword = "PASSWORD"
    Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, "noetpad.exe", "", @SW_SHOWMAXIMIZED)
    ; Run Notepad with the window maximized. Notepad is run under the user previously specified.
;~     RunWait(@WindowsDir & "C:\automation\TestScripts\Writefilter.exe", @WindowsDir, @SW_MAXIMIZE)
EndFunc 

 

Edited by PramodR
added additional info
Link to comment
Share on other sites

i am really sotrry for that silly mistake , i was trying different files and accidentally mistypes...  is it okay if i replace it with complete path to my exec instead of notepad ?

below command i replaced and i get the error again as errorstd out..    Thanks Subs in advance.. 

Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, 0, "C:\executeauto\Testfilter.exe", "", @SW_SHOWMAXIMIZED)
Link to comment
Share on other sites

Is that the complete script above, because it works fine for me.  Can you post the entire code?  Can you also post screenshot of the error, because not sure where it's coming from.  Are you sure the error is the script i.e. if you run from within Scite do you get the error?  I suspect the error is occurring during Build which usually means that the programs is already running in the background and can't be overwritten.

Link to comment
Share on other sites

What error?

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

Link to comment
Share on other sites

That's not an error. That's part of the command line when you run a script so you can see it in the console.

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

Link to comment
Share on other sites

14 minutes ago, Subz said:

suspect the error is occurring during Build which usually means that the programs is already running in the background and can't be overwritten.

Thanks Guys for Help.  :) . This Forum Rocks

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

×
×
  • Create New...