cpremo Posted May 21, 2009 Share Posted May 21, 2009 (edited) I'm desperate!!! I've tried to write code that would enable me to run an application installation as an Administrator. My environment consists of Win XP PCs that are NOT part of a WIN Domain!! (We are a Novell Environment.) Most users (95%) only have USER rights to their PC. I desperately need code to run an application update using the PCs Administrators rights. Any and All help will be greatly appreciated.$sUsername = 'administrator' $sPassword = 'password' $sDomain = @ComputerName If $CMDLine[0] = 0 Then RunAs($sUsername, $sDomain, $sPassword, 0, "W:\Novell - GroupWise Client\client 7.0.3\win32\setup.exe", @SystemDir, @SW_SHOW) ;@AutoItExe & ' Exit EndIf Edited May 22, 2009 by cpremo Link to comment Share on other sites More sharing options...
Developers Jos Posted May 21, 2009 Developers Share Posted May 21, 2009 (edited) Probably the local Administrator doesn't have rights to read the file from the Novell server? If so you could first copy it to the local pc after which you Run it with the elevated rights. Jos Edited May 21, 2009 by 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 More sharing options...
cpremo Posted May 22, 2009 Author Share Posted May 22, 2009 Some one had given me this code which works, but requires user intervention (ie. putting in the password). Is there some other code that can be added to "pass the password" to the Run as Dialog box??? #RequireAdmin ; Fill in the username and password appropriate for your system. Local $sUserName = "administrator" Local $sPassword = "password" Dim $Filename = IniRead ( @ScriptDir & "\SciTE.ini", "CommandData", "EXEFile", "default" ) $Domain = @ComputerName If Not IsAdmin() Then ; Run a command prompt as the other user. Local $pid = RunAs($sUserName, $Domain, $sPassword, 4, RunWait($Filename), @ScriptDir) ; Wait for the process to close. ProcessWaitClose($pid) Else Run($Filename, @ScriptDir, @SW_HIDE) EndIf Link to comment Share on other sites More sharing options...
Developers Jos Posted May 22, 2009 Developers Share Posted May 22, 2009 (edited) Have you tried what I suggested? something like: $sUsername = 'administrator' $sPassword = 'password' $sDomain = @ComputerName If $CMDLine[0] = 0 Then Filecopy("W:\Novell - GroupWise Client\client 7.0.3\win32\setup.exe",@ScriptDir & "\setup.exe",1) RunAs($sUsername, $sDomain, $sPassword, 0, @ScriptDir & "\setup.exe", @SystemDir, @SW_SHOW) Exit EndIf EDIT: This assumes that he script is running from the local harddisk. Edited May 22, 2009 by 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now