Jump to content
Sign in to follow this  
cpremo

RunAs Administrator

Recommended Posts

cpremo

I've created a script as shown but it doesn't work. What's wrong???? The application starts installing but when it gets to installing files in the "C:\Windows\system32" directory it fails stating "Error 1321.The installer has insufficient privileges to modify the file C:\Windows\system32\gwenv1.dll"

Script

***************************************************************************************

; 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

***************************************************************************************

SciTE.ini

***************************************************************************************

[CommandData]
EXEFile="W:\Novell - GroupWise Client\client 7.0.3\win32\setup.exe"

[LogoData]
Destination1="C:\Windows\"
Destination2=C:\WINNT\
****************************************************************************************

Share this post


Link to post
Share on other sites
dgarrett8

You have vista?


"I think, therefore I am"[size="1"]René Descartes[/size]

Share this post


Link to post
Share on other sites
isolation

Local $sUserName = "administrator"
    Local $sPassword = "password"
    Dim $Filename = IniRead ( @ScriptDir & "\SciTE.ini", "CommandData", "EXEFile", "default" )
    $Domain = @ComputerName
    
If Not IsAdmin() Then
    $pid = RunAsWait($sUserName, $Domain, $sPassword, 4, $Filename)
Else
    $pid = Run($Filename, @ScriptDir, @SW_HIDE)
EndIf

well... I'm a newbie but...try...

Share this post


Link to post
Share on other sites
cpremo

:):)

DOESN'T ANY BODY RUN A SCRIPT INVOKING ADMIN PRIVILEGES?????

Share this post


Link to post
Share on other sites
LarryDalooza

I use something like this to "rerun" my script as an interactive admin. I have never had problems, unless!!!, my credentials are not a "local admin". Your credentials must be local admin.

If Not IsAdmin() Then
    If $CMDLINE[0] = 0 Or $CMDLINE[1] <> "ReRun" Then
        If Not RunAs("admin","MyDomain","password",1,"""" & @ScriptFullPath & """ ReRun",@ScriptDir) Then Exit 1
        Exit 0
    Else
        MsgBox(4096,"ReRun","ReRun failed.")
        Exit 1
    EndIf
EndIf
MsgBox(4096,"","I am an Admin")

make some short tests for yourself before bothering us too much. Chances are it's entirely your mistake.

Lar.

Edited by LarryDalooza

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites
cpremo

I use something like this to "rerun" my script as an interactive admin. I have never had problems, unless!!!, my credentials are not a "local admin". Your credentials must be local admin.

If Not IsAdmin() Then
    If $CMDLINE[0] = 0 Or $CMDLINE[1] <> "ReRun" Then
        If Not RunAs("admin","MyDomain","password",1,"""" & @ScriptFullPath & """ ReRun",@ScriptDir) Then Exit 1
        Exit 0
    Else
        MsgBox(4096,"ReRun","ReRun failed.")
        Exit 1
    EndIf
EndIf
MsgBox(4096,"","I am an Admin")

make some short tests for yourself before bothering us too much. Chances are it's entirely your mistake.

Lar.

Sorry if I'm a little dense, but . . .

What do the $CMDLINE value refer to. It's not part of my code, so it must be something in your complete coded script. Either way, it fails to do anything on my test PC. And yes, we don't have a Windows Domain and are trying to use Local admin credentials. We are a Novell shop and use local accounts to authenticate to the PCs as well as loging into to our Novell domain.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.