Sign in to follow this  
Followers 0
cpremo

RUN AS Admin on PC

4 posts in this topic

#1 ·  Posted (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 by cpremo

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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