Jump to content
Sign in to follow this  

Windows 7 Executing BATH as admin

Recommended Posts

Hey all, trying to automate an office 2010 install.

Working fine on XP but no-go on Win7.

Even though I am forcing admin execution, the script still refuses to actually launch the batch script as admin.

#include <GUIConstants.au3>

$hWnd = GUICreate ("Processing..", 300, 150)
$Edit = GUICtrlCreateEdit ("Webster Computers Office 2010 Auto-Installer" & @CRLF & "Starting installation process" & @CRLF, 5, 5, 290, 140)
GUISetState (@SW_SHOW)

$TempDir = @HomeDrive & "\" & Random (1, 99999, 1)

DirCreate ($TempDir)
If @error Then
    MsgBox (48, "Error", "Could not create directory at " & $TempDir)
    Exit 0
_LOG("Created temp directory at " & $TempDir)
_LOG("Copying files to " & $TempDir & " please wait..")
DirCopy (@ScriptDir, $TempDir, 1)
_LOG("Finished cache file copy, installing Office 2010")
If IsAdmin() Then
    $PID = Run ($TempDir & "\oemsetup.en-us.bat", $TempDir)

    While 1
        $user = InputBox ("Admin-Logon", "You must be an Administrator to continue setup." & @CRlf & "Please enter your username:", "Administrator")
        $pass = InputBox ("Admin-Logon", "Please enter your password", "", "*")
        If $user <> "" AND $pass <> "" Then
            $PID = RunAs ($user, @ComputerName, $pass, 0, $TempDir & "\oemsetup.en-us.bat", $TempDir)
            If @error Then
                MsgBox (48, "Authentication Error", "You have entered an invalid username / password")


While 1

    If not ProcessExists ($PID) Then

    Sleep (50)


Sleep (1000)
_LOG("Installer Finished, removing Temp directory at " & $TempDir)
DirRemove ($TempDir, 1)
MsgBox (32, "Success", "Finished installing successfully")

Func _LOG($string)

    GUICtrlSetData ($Edit, GUICtrlRead ($Edit) & $string & @CRLF)
    ConsoleWrite ($string & @CRLF)

Edited by Dampe

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...