Sign in to follow this  
Followers 0
Anaxibius

I do not get RunAsSet

4 posts in this topic

#1 ·  Posted (edited)

RunAsSet is killing me! Why in the world would the follwoing script not run the xcopy RunWait line when using admin rights set in the initial RunAsSet? I know the RunAsSet is working because the uninstall function correctly, where it wouldn't otherwise. If I remove the RunAsSet the xcopy works...what gives?!!!! (!!!! = lots of frustration.)

AutoItSetOption("RunErrorsFatal", 0)
AutoItSetOption("TrayIconHide", 1)

Global $Source, $IP, $Key, $Directory

$Test = StringLeft(@IPAddress1, 6)
If $Test <> "10.179" Then
    $IP = StringMid(@IPAddress2, 8, 2)
Else
    $IP = StringMid(@IPAddress1, 8, 2)
EndIf

If $IP = "31" Then
    $Source = "\\lvfp1\software$"
ElseIf $IP = "32" Then
    $Source = "\\lvfp1\software$"
ElseIf $IP = "34" Then
    $Source = "\\lvfp1\software$"
ElseIf $IP = "35" Then
    $Source = "\\lvfp1\software$"
ElseIf $IP = "36" Then
    $Source = "\\lvfp1\software$"
ElseIf $IP = "37" Then
    $Source = "\\lvfp1\software$"
ElseIf $IP = "16" Then
    $Source = "\\drfp2\software$"
ElseIf $IP = "38" Then
    $Source = "\\psfp2\software$"
ElseIf $IP = "42" Then
    $Source = "\\ahfp2\software$"
ElseIf $IP = "43" Then
    $Source = "\\bgfp2\software$"
ElseIf $IP = "44" Then
    $Source = "\\crfp2\software$"
ElseIf $IP = "45" Then
    $Source = "\\evfp2\software$"
ElseIf $IP = "46" Then
    $Source = "\\lxfp2\software$"
ElseIf $IP = "47" Then
    $Source = "\\pdfp2\software$"
ElseIf $IP = "48" Then
    $Source = "\\pkfp2\software$"
ElseIf $IP = "49" Then
    $Source = "\\hzfp2\software$"
ElseIf $IP = "50" Then
    $Source = "\\amfp2\software$"
ElseIf $IP = "51" Then
    $Source = "\\amfp2\software$"
EndIf
;Running Installation as Administrator
$USERNAME = "administrator"
$PASSWORD = "somepassword"
$DOMAIN = "somedomain.com"
$RegVal = RegRead( "HKEY_LOCAL_MACHINE\SOFTWARE\CLAAS E.S.I.S\2.00.000\Setup", "Version")
If $RegVal <> "2.50.800" Then
;Setting Script to run as administrator.
    Opt("WinWaitDelay",100)
    Opt("WinTitleMatchMode",4)
    Opt("WinDetectHiddenText",1)
    Opt("MouseCoordMode",0)
    RunAsSet($USERNAME,$DOMAIN,$PASSWORD)
;Checking to see if the uninstall file for the previous version exists.  Execute uninstall if present.
    If FileExists("C:\Program Files\InstallShield Installation Information\{E5D7C143-32F3-437C-A84A-122563E25682}\Setup.exe") Then
        Run('"C:\Program Files\InstallShield Installation Information\{E5D7C143-32F3-437C-A84A-122563E25682}\Setup.exe" -uninst -removeonly' )
;Sending Keyboard commands to uninstall program.
        If Not WinActive("CLAAS E.S.I.S Caterpillar", "CLAAS E.S.I.S Caterpillar has been successfully") Then
            WinActivate("CLAAS E.S.I.S Caterpillar", "CLAAS E.S.I.S Caterpillar has been successfully")
            Sleep(1000)
            Send("!y")
            Sleep(9000)
            Send("{ENTER}")
        EndIf
    EndIf
;Removing old directory in place of removing contents.
$OldFolder = DirGetSize("C:\CLAASCAT")
If $OldFolder <> -1 Then
    RunWait($Source & "\CLAAS\DirRemove.exe")
EndIf
MsgBox(0,"Debug", "Good so far")
DirCreate("c:\ClaasCat")
DriveMapAdd("x:", $Source)
Sleep(1000)
RunWait(@ComSpec & " /c " & "xcopy /Y/E/F/H/R x:\CLAAS\v2.5.8\*.* c:\CLAASCAT")
DriveMapDel("x:")
;Executing setup
    Run('C:\ClaasCat\Setup.exe /s /v"qn"')
    WinWait("CLAAS E.S.I.S Caterpillar Setup","The drive specificat")
;Sending Keyboard commands to Installation Program.
    If Not WinActive("CLAAS E.S.I.S Caterpillar Setup","The drive specificat") Then WinActivate("CLAAS E.S.I.S Caterpillar Setup","The drive specificat")
        WinWaitActive("CLAAS E.S.I.S Caterpillar Setup","The drive specificat")
        Sleep(1000)
        Send("!n")
        FileCopy("C:\ClaasCat\Temp\claas.ini", "C:\CLAASCAT\ClaasApp\", 1)
        RunAsSet()
Else
    MsgBox(0,"Claas Installation", "It appears that Claas v2.5.8 has been previously installed on this computer.  Please contact the help desk for further help.", 20)
EndIf
Exit

If I run this once with the RunAsSet in place it will uninstall the old application and fail at the copy. If I remove the RunAsSet it will skip over the uninstall (as I said I removed it by running with RunAsSet) and copies the files. Simply put I cannot get everything to work under RunAsSet. I am desperate for help. I have removed any variables that depend on profiles or macros, so I am completely lost now.

Edited by Anaxibius

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You sir are a genius and I am a moron. I have been banging my head against this for a week in one form or another.

Edited by Anaxibius

Share this post


Link to post
Share on other sites

I think the RunAsSet is not applying to xcopy but to the command prompt that runs it. It may be worth using DirCopy instead.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I think the RunAsSet is not applying to xcopy but to the command prompt that runs it. It may be worth using DirCopy instead.

You are probably right. The issue is that I need a visual representation that shows files copying. If my users don't see something flashing across their screens every 2 seconds they will assume it is done and take their laptops off the network. That is why i fiddled witha progress bar for a week and then xcopy. Thanks for help. Changing it to the UNC path fixed it.

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