#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=panagenda.ico #AutoIt3Wrapper_UseUpx=Y #AutoIt3Wrapper_Res_Description=panagenda MarvelClient Upgrade Launcher #AutoIt3Wrapper_Res_Fileversion=4.0.3.0 #AutoIt3Wrapper_Res_ProductVersion=4.0.3.0 #AutoIt3Wrapper_Res_LegalCopyright=Copyright ©2007-2015 panagenda® #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Res_Field=CompanyName|panagenda #AutoIt3Wrapper_Res_Field=ProductName|panagenda MarvelClient Upgrade Launcher #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#include #include #include ;#include ;#include ;#include ;for SMTP email updates #pragma compile(FileVersion, 4.0.3.0) #pragma compile(ProductVersion, 4.0.3.0) #pragma compile(CompanyName, 'panagenda') #pragma compile(ProductName, panagenda MarvelClient Upgrade Launcher) #pragma compile(FileDescription, panagenda MarvelClient Upgrade Launcher) #pragma compile(LegalCopyright, Copyright ©2007-2015 panagenda®) #pragma compile(Icon, panagenda.ico) #pragma compile(ExecLevel, asInvoker) ;~ #pragma compile(UPX, True) ; Commented out by AutoIt3Wrapper to be able to do the requested resource updates ;#AutoIt3Wrapper_Change2CUI=y #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author: panagenda Script Function: Logon as Administrator. Replace AdminUserName below with name of Administrator account Replace Password below with password of Administrator account IMPORTANT: After compiling the script, delete the uncompiled script to make sure that the admin account details are not stored anywhere in plain text! ;3.3.0.1 = fixed domain name not being used for mapping drives ;3.3.0.1 = added RestoreNetworkDriveMappingsOption ;3.3.0.2 = fixed UseComspec=0 - failed due to ""program" "ini"" instead of "program" "ini" ;3.3.0.3 = cleaned up code for final 3.3.0.3 release ;3.3.0.4 = added $ht_checkfile = StringReplace($ht_checkfile, "%MC_UPGRADEDIRECTORY%", $MC_MYUPGRADEDIRECTORY) to support %MC_UPGRADEDIRECTORY% placeholder in DeferralFilesMustExist* entries ;3.3.0.5 = added $ht_checkfile = StringReplace($ht_checkfile, "%MC_>>>MY<< "\" Then $currentdirectory = $currentdirectory & "\" If $CmdLine[0] < 1 Then $runupgradeexe = $currentdirectory & "\MCUpgrade.exe" Else $runupgradeexe = $CmdLine[1] EndIf $ht_autoitexe_short = FileGetShortName(@AutoItExe) $runupgradeexe_short = FileGetShortName($runupgradeexe) Global $ht_inifilepath = "" $ht_inifilepath_short = "" If $CmdLine[0] > 1 And Not StringIsDigit($CmdLine[2]) Then $ht_inifilepath = $CmdLine[2] $ht_runcount = 0 If $CmdLine[0] = 2 Then If StringIsDigit($CmdLine[2]) Then $ht_runcount = $CmdLine[2] EndIf If $CmdLine[0] = 3 Then If StringIsDigit($CmdLine[3]) Then $ht_runcount = $CmdLine[3] EndIf $ht_runcount = $ht_runcount + 1 If $ht_inifilepath = "" And FileExists($currentdirectory & "\MCUpgrade.ini") Then $ht_inifilepath = $currentdirectory & "\MCUpgrade.ini" EndIf If $ht_inifilepath = "" Then $MC_MYUPGRADEDIRECTORY = $currentdirectory $MC_UPGRADELOGFILE = $currentdirectory & "\MCUpgrade.log" $MC_UPGRADELOGFILE = StringReplace($MC_UPGRADELOGFILE, "%MC_UPGRADEDIRECTORY%", $MC_MYUPGRADEDIRECTORY) $MC_UPGRADELOGFILE = StringReplace($MC_UPGRADELOGFILE, "%MC_MYUPGRADEDIRECTORY%", $MC_MYUPGRADEDIRECTORY) $MC_RESETLOG = "1" $MC_DEFERRAL_PROMPT = "0" $MC_DEFERRAL_PROMPTS_MAX = 0 $MC_DEFERRAL_DAYS_MAX = 0 $MC_GRACEFULSHUTDOWN = 0 $MC_USE_COMSPEC = 1 $MC_LOGON_FLAG = 0 $MC_PERMUTATED_LOGON = 1 Else $ht_inifilepath = FileGetLongName($ht_inifilepath) If StringInStr($ht_inifilepath, ".ini") > 0 Then $ht_inideferralpath = StringReplace($ht_inifilepath, ".ini", "_deferral.ini") Else $ht_inideferralpath = $ht_inifilepath + "_deferral" EndIf $ht_inifilepath_short = FileGetShortName($ht_inifilepath) AutoItSetOption("ExpandEnvStrings", 1) $MC_SOURCEDIRECTORY = IniRead($ht_inifilepath, "MCUpgrade", "NotesDataDirectoryOld", "") $MC_TARGETDIRECTORY = IniRead($ht_inifilepath, "MCUpgrade", "NotesDataDirectoryNew", "") $MC_MYUPGRADEDIRECTORY = IniRead($ht_inifilepath, "MCUpgrade", "UpgradeDirectory", $currentdirectory) $MC_UPGRADELOGFILE = IniRead($ht_inifilepath, "MCUpgrade", "LogFile", $currentdirectory & "\MCUpgrade.log") $MC_UPGRADELOGFILE = StringReplace($MC_UPGRADELOGFILE, "%MC_UPGRADEDIRECTORY%", $MC_MYUPGRADEDIRECTORY) $MC_UPGRADELOGFILE = StringReplace($MC_UPGRADELOGFILE, "%MC_MYUPGRADEDIRECTORY%", $MC_MYUPGRADEDIRECTORY) $MC_INSTALLFINISHEDEXEC = IniRead($ht_inifilepath, "MCUpgrade", "InstallFinishedExec", "") AutoItSetOption("ExpandEnvStrings", 0) $MC_RESETLOG = IniRead($ht_inifilepath, "MCUpgrade", "SURunAsResetLogOnFirstRun", "1") $MC_DEFERRAL_PROMPT = IniRead($ht_inifilepath, "MCUpgrade", "DeferralPrompt", "0") $MC_DEFERRAL_PROMPT_TITLE = IniRead($ht_inifilepath, "MCUpgrade", "DeferralPromptTitle", "Update") $MC_DEFERRAL_PROMPT_MESSAGE = StringReplace(IniRead($ht_inifilepath, "MCUpgrade", "DeferralPromptMessage", "Do you want to upgrade your client experience?@LF@You have %DAYSLEFT% days / %PROMPTSLEFT% times left to choose ""No"" before the upgrade will be performed automatically."), "@LF@", @LF) $MC_DEFERRAL_PROMPTS_MAX = Number(IniRead($ht_inifilepath, "MCUpgrade", "DeferralNumberOfUpdatePromptsMax", 0)) $MC_DEFERRAL_DAYS_MAX = Number(IniRead($ht_inifilepath, "MCUpgrade", "DeferralNumberOfDaysMax", 0)) $MC_DEFERRAL_PROMPT_FIRST = Number(IniRead($ht_inideferralpath, "MCUpgrade", "DeferralPromptFirst", "")) $MC_DEFERRAL_PROMPT_LAST = Number(IniRead($ht_inideferralpath, "MCUpgrade", "DeferralPromptLast", "")) $MC_DEFERRAL_PROMPT_COUNT = Number(IniRead($ht_inideferralpath, "MCUpgrade", "DeferralPromptCount", 0)) $MC_GRACEFULSHUTDOWN = Number(IniRead($ht_inifilepath, "MCUpgrade", "GracefulShutdown", 1)) $MC_USE_COMSPEC = Number(IniRead($ht_inifilepath, "MCUpgrade", "UseComspec", 1)) $MC_LOGON_FLAG = Number(IniRead($ht_inifilepath, "MCUpgrade", "LogonFlag", 0)) $MC_PERMUTATED_LOGON = Number(IniRead($ht_inifilepath, "MCUpgrade", "PermutatedLogon", 1)) EndIf Global $flg_othersurunasinprogress=0 if $ht_inifilepath<>"" Then if IniRead($ht_inifilepath, "MCUpgrade", "SuRunAsInProgress", "")="" Then IniWrite($ht_inifilepath, "MCUpgrade", "SuRunAsInProgress", "1") Else $flg_othersurunasinprogress=1 EndIf EndIf If $MC_UPGRADELOGFILE <> "" Then AutoItSetOption("ExpandEnvStrings", 1) If $MC_RESETLOG = 1 And $ht_runcount = 1 Then $MC_LOGFILEHANDLE = FileOpen($MC_UPGRADELOGFILE, 2) Else $MC_LOGFILEHANDLE = FileOpen($MC_UPGRADELOGFILE, 1) EndIf ; Check if file opened for writing OK If $MC_LOGFILEHANDLE = -1 Then MsgBox(0, "Error", "Unable to open MCUpgrade log file [" & $MC_UPGRADELOGFILE & "] - operation aborted.") _MyExit() EndIf AutoItSetOption("ExpandEnvStrings", 0) Else $MC_LOGFILEHANDLE = -2 EndIf if $flg_othersurunasinprogress=1 Then if $ht_runcount <= 1 Then _MCUpgradeLogging(-1, "WARNING: Parallel SuRunAs run detected - another Upgrade is already in progress - exiting.", 0) _MyExit() Else _MCUpgradeLogging(-1, "NOTE: Parallel SuRunAs run detected - however, this is a re-run [" & $ht_runcount & "] - continuing ...", 0) EndIf EndIf if ($MC_PERMUTATED_LOGON=0) Then if Not (UBound($sec_adminusernames)=UBound($sec_adminuserpasswords)) Then _MCUpgradeLogging(-1, "WARNING: PermutatedLogon was set to [0], but the number of logon parameters is not correct - switching to permutated logon", 0) $MC_PERMUTATED_LOGON=1 EndIf EndIf EnvSet("MC_MYUPGRADEDIRECTORY", $MC_MYUPGRADEDIRECTORY) EnvSet("MC_UPGRADEDIRECTORY", $MC_MYUPGRADEDIRECTORY) _MCUpgradeLogging(-1, "***** panagenda MarvelClient Upgrade Launcher " & FileGetVersion(@AutoItExe) & " - (C)2007-" & @YEAR & " ***** (IsAdmin=" & IsAdmin() & ")", 0) _MCUpgradeLogging(-1, "Running on [" & @OSVersion & ", " & @OSArch & "]", 0) _MCUpgradeLogging(-1, "Running as [" & @UserName & "]", 0) _MCUpgradeLogging(-1, "Switching current/working directory to [" & $currentdirectory & "] ...", 0) FileChangeDir($currentdirectory) IniWrite($ht_inifilepath, "MCUpgrade", "PreviousUser", @UserName) if $ht_inifilepath="" Then _MCUpgradeLogging(-1, "WARNING: No MCUpgrade.ini file specified - unable to memorize current user's Desktop & Start Menu folders", 0) Else Const $Desktop = 0x10 Const $Start_Menu = 0xb $objShell = ObjCreate("Shell.Application") If (IsObj($objShell) = 0) Or ($g_eventerror = 1) Then _MCUpgradeLogging(-1, "WARNING: Could not get Shell.Application object for locating special folders ... SKIPPING memorizing if current user's Desktop & Start Menu folders", 0) $g_eventerror=0 IniWrite($ht_inifilepath, "MCUpgrade", "PreviousUserDesktopFolder", "") IniWrite($ht_inifilepath, "MCUpgrade", "PreviousUserStartMenuFolder", "") Else _MCUpgradeLogging(-1, "Getting current user's Desktop folder ...", 0) $ht_current_user_desktop_folder=_Special_Folder($Desktop) _MCUpgradeLogging(-1, "= [" & $ht_current_user_desktop_folder & "]", 0) _MCUpgradeLogging(-1, "Getting current user's Start Menu folder ...", 0) $ht_current_user_start_menu_folder=_Special_Folder($Start_Menu) _MCUpgradeLogging(-1, "= [" & $ht_current_user_start_menu_folder & "]", 0) IniWrite($ht_inifilepath, "MCUpgrade", "PreviousUserDesktopFolder", $ht_current_user_desktop_folder) IniWrite($ht_inifilepath, "MCUpgrade", "PreviousUserStartMenuFolder", $ht_current_user_start_menu_folder) EndIf EndIf _MCUpgradeLogging(-1, "Logon Flag is set to [" & $MC_LOGON_FLAG & "]", 0) _MCUpgradeLogging(-1, "Comspec use is set to [" & $MC_USE_COMSPEC & "]", 0) If $ht_inifilepath <> "" Then For $i = 1 To 999 $i3 = StringRight("000" & $i, 3) AutoItSetOption("ExpandEnvStrings", 1) $ht_checkfile = IniRead($ht_inifilepath, "MCUpgrade", "DeferralFileMustExist" & $i3, "") If $ht_checkfile = "" Then ExitLoop _MCUpgradeLogging(-1, "Checking for whether file [" & $ht_checkfile & "] exists ...", 0) If FileExists($ht_checkfile) Then _MCUpgradeLogging(-1, "... found", 0) Else _MCUpgradeLogging(-1, "... NOT found - operation aborted", 0) _MyExit() EndIf AutoItSetOption("ExpandEnvStrings", 0) Next EndIf _MCUpgradeLogging(-1, "Date/Time now is [" & @YEAR & @MON & @MDAY & "/" & @HOUR & @MIN & @SEC & "]", 0) $MC_DEFERRAL = "0" If (($MC_DEFERRAL_PROMPT <> "0") And ($ht_runcount = 1)) Then _MCUpgradeLogging(-1, "Deferral prompt is enabled [" & $MC_DEFERRAL_PROMPT & "]", 0) _MCUpgradeLogging(-1, "Maximum number of deferral days is [" & $MC_DEFERRAL_DAYS_MAX & "]", 0) _MCUpgradeLogging(-1, "Maximum number of deferrals is [" & $MC_DEFERRAL_PROMPTS_MAX & "]", 0) If $MC_DEFERRAL_PROMPT_FIRST = "" Then $MC_DEFERRAL_PROMPT_FIRST = @YEAR & @MON & @MDAY IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptFirst", $MC_DEFERRAL_PROMPT_FIRST) _MCUpgradeLogging(-1, "First ever deferral prompt set to today [" & $MC_DEFERRAL_PROMPT_FIRST & "]", 0) $MC_DEFERRAL_PROMPT_COUNT = 0 IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptCount", $MC_DEFERRAL_PROMPT_COUNT) Else _MCUpgradeLogging(-1, "First deferral prompt was on [" & $MC_DEFERRAL_PROMPT_FIRST & "]", 0) EndIf $MC_DEFERRAL_PROMPT_FIRST_DATE = StringRegExpReplace($MC_DEFERRAL_PROMPT_FIRST, "(\d{4})(\d{2})(\d{2})", "$1/$2/$3") $MC_DEFERRAL_PROMPT_FIRST_DATE_CHECK = _DateTimeFormat($MC_DEFERRAL_PROMPT_FIRST_DATE, 0) If $MC_DEFERRAL_PROMPT_FIRST_DATE_CHECK = "" Then _MCUpgradeLogging(-1, "Resetting first deferral prompt - could not parse last stored (includes resetting prompt count)", 0) $MC_DEFERRAL_PROMPT_FIRST = @YEAR & @MON & @MDAY IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptFirst", $MC_DEFERRAL_PROMPT_FIRST) $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW = 0 $MC_DEFERRAL_PROMPT_COUNT = 0 IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptCount", $MC_DEFERRAL_PROMPT_COUNT) Else $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW = _DateDiff("D", $MC_DEFERRAL_PROMPT_FIRST_DATE, _NowCalc()) If $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW < 0 Then $MC_DEFERRAL_PROMPT_FIRST = @YEAR & @MON & @MDAY _MCUpgradeLogging(-1, "Resetting first ever deferral prompt to [" & $MC_DEFERRAL_PROMPT_FIRST & "] (includes resetting prompt count)", 0) IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptFirst", $MC_DEFERRAL_PROMPT_FIRST) $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW = 0 $MC_DEFERRAL_PROMPT_COUNT = 0 IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptCount", $MC_DEFERRAL_PROMPT_COUNT) EndIf EndIf $MC_DEFERRAL = "1" If $MC_DEFERRAL_PROMPT = "1" Then _MCUpgradeLogging(-1, "Deferral prompt set to max. once a day", 0) If $MC_DEFERRAL_PROMPT_LAST = "" Then ;first ever prompt - so "today" no prompt happened yet Else _MCUpgradeLogging(-1, "Last deferral prompt was on [" & $MC_DEFERRAL_PROMPT_LAST & "]", 0) $MC_DEFERRAL_PROMPT_LAST_DATE = StringRegExpReplace($MC_DEFERRAL_PROMPT_LAST, "(\d{4})(\d{2})(\d{2})", "$1/$2/$3") $MC_DEFERRAL_PROMPT_LAST_DATE_CHECK = _DateTimeFormat($MC_DEFERRAL_PROMPT_LAST_DATE, 0) If $MC_DEFERRAL_PROMPT_LAST_DATE_CHECK = "" Then $MC_DEFERRAL_PROMPT_LAST = "" _MCUpgradeLogging(-1, "Resetting last deferral prompt - could not parse last stored", 0) IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptLast", $MC_DEFERRAL_PROMPT_LAST) Else $MC_DEFERRAL_PROMPT_LAST_DIFF_TO_NOW = _DateDiff("D", $MC_DEFERRAL_PROMPT_LAST_DATE, _NowCalc()) _MCUpgradeLogging(-1, "Number of days since last prompt: [" & $MC_DEFERRAL_PROMPT_LAST_DIFF_TO_NOW & "]", 0) If $MC_DEFERRAL_PROMPT_LAST_DIFF_TO_NOW > 0 Then ;prompt again $MC_DEFERRAL = "1" _MCUpgradeLogging(-1, "User was not yet prompted today ...", 0) Else ;don't prompt again today $MC_DEFERRAL = "2" _MCUpgradeLogging(-1, "User was already prompted today ...", 0) EndIf EndIf EndIf Else _MCUpgradeLogging(-1, "Deferral prompt set to always", 0) EndIf _MCUpgradeLogging(-1, "Number of days since first prompt: [" & $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW & "]", 0) _MCUpgradeLogging(-1, "Number of deferrals since first prompt: [" & $MC_DEFERRAL_PROMPT_COUNT & "]", 0) $MC_DEFERRAL_PROMPT_COUNT = $MC_DEFERRAL_PROMPT_COUNT + 1 If $MC_DEFERRAL_PROMPTS_MAX > 0 And $MC_DEFERRAL_PROMPT_COUNT > $MC_DEFERRAL_PROMPTS_MAX Then _MCUpgradeLogging(-1, "Number of deferrals exceeds maximum [" & $MC_DEFERRAL_PROMPTS_MAX & "] - enforcing upgrade ...", 0) $MC_DEFERRAL = "0" EndIf If $MC_DEFERRAL_DAYS_MAX > 0 And $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW > $MC_DEFERRAL_DAYS_MAX Then _MCUpgradeLogging(-1, "Number of days since first prompt exceeds maximum [" & $MC_DEFERRAL_DAYS_MAX & "] - enforcing upgrade ...", 0) $MC_DEFERRAL = "0" EndIf If $MC_DEFERRAL = "1" Then $MC_DEFERRAL_PROMPT_MESSAGE = StringReplace($MC_DEFERRAL_PROMPT_MESSAGE, "%DAYSLEFT%", $MC_DEFERRAL_DAYS_MAX - $MC_DEFERRAL_PROMPT_FIRST_DIFF_TO_NOW) $MC_DEFERRAL_PROMPT_MESSAGE = StringReplace($MC_DEFERRAL_PROMPT_MESSAGE, "%PROMPTSLEFT%", $MC_DEFERRAL_PROMPTS_MAX - $MC_DEFERRAL_PROMPT_COUNT + 1) $MC_DEFERRAL_CHOICE = MsgBox(4 + 32 + 4096, $MC_DEFERRAL_PROMPT_TITLE, $MC_DEFERRAL_PROMPT_MESSAGE) IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptCount", $MC_DEFERRAL_PROMPT_COUNT) IniWrite($ht_inideferralpath, "MCUpgrade", "DeferralPromptLast", @YEAR & @MON & @MDAY) If $MC_DEFERRAL_CHOICE = 6 Then $MC_DEFERRAL = "0" _MCUpgradeLogging(-1, "User chose to run upgrade ...", 0) Else _MCUpgradeLogging(-1, "User chose to not to run upgrade yet - exiting", 0) _MyExit() EndIf EndIf EndIf If $MC_DEFERRAL = "0" Then ;$MC_DEFERRAL can be 0, 1 or 2 - 0=not deferred (any more), 1=deferred, 2=deferred for today _MCUpgradeLogging(-1, "Upgrade is NOT deferred - continuing ...", 0) Else If $ht_runcount = 1 Then _MCUpgradeLogging(-1, "Upgrade is deferred - exiting.", 0) _MyExit() Else $MC_DEFERRAL = "0" $MC_GRACEFULSHUTDOWN = 0 _MCUpgradeLogging(-1, "Upgrade deferral is ignored (this is a re-run).", 0) EndIf EndIf _MCUpgradeLogging(-1, "Checking for whether [" & $runupgradeexe & "] exists ...", 0) If FileExists($runupgradeexe) = 0 Then _MCUpgradeLogging(-1, "WARNING: Could not find [" & $runupgradeexe & "] - might be executable via OS path --> continuing ...", 0) Else _MCUpgradeLogging(-1, "Successfully found [" & $runupgradeexe & "].", 0) EndIf If $MC_GRACEFULSHUTDOWN = 1 Then if not FileExists($currentdirectory & "\MCShutdown.exe") Then _MCUpgradeLogging(-1, "WARNING: Could not find [" & $currentdirectory & "\MCShutdown.exe] - could not initiate graceful shutdown ...", 0) Else IniDelete($ht_inifilepath, "MCUpgrade", "ShutdownResult") IniDelete($ht_inifilepath, "MCUpgrade", "ShutdownCancelled") _MCUpgradeLogging(-1, "Launching [" & FileGetShortName($currentdirectory & "\MCShutdown.exe") & " " & $ht_inifilepath_short & "] ...", 0) _CloseLog() RunWait(FileGetShortName($currentdirectory & "\MCShutdown.exe") & " " & $ht_inifilepath_short, $currentdirectory, @SW_HIDE) $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) $result_close=IniRead($ht_inifilepath, "MCUpgrade", "ShutdownResult", "") $flg_Graceful_Shutdown_Cancelled=IniRead($ht_inifilepath, "MCUpgrade", "ShutdownCancelled", 0) IniDelete($ht_inifilepath, "MCUpgrade", "ShutdownResult") IniDelete($ht_inifilepath, "MCUpgrade", "ShutdownCancelled") _MCUpgradeLogging(-1, "... [" & $currentdirectory & "\MCShutdown.exe] returned:", 0) If $flg_Graceful_Shutdown_Cancelled=1 Then _MCUpgradeLogging(-1, "User cancelled graceful shutdown, exiting ...", 0) _MyExit() EndIf If $result_close=-1 Then _MCUpgradeLogging(-1, "No relevant windows found left open - continuing ...", 0) ElseIf $result_close=0 Then _MCUpgradeLogging(-1, "All relevant windows closed successfully - continuing ...", 0) Else if $MC_GRACEFULSHUTDOWN=1 Then _MCUpgradeLogging(-1, "Failed to close all relevant windows - exiting due to GraceFulShutdown=1 ...", 0) _MyExit() Else _MCUpgradeLogging(-1, "Failed to close all relevant windows - continuing due to GraceFulShutdown=2 ...", 0) EndIf EndIf EndIf EndIf $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $Output = "" $adminGroup = "" $islocaladmin = -1 ;$builtinAdminGroup = (Get-WmiObject -Class Win32_Group -computername $env:COMPUTERNAME -Filter "SID='S-1-5-32-544' AND LocalAccount='True'" -errorAction "Stop").Name _MCUpgradeLogging(-1, "Getting winmgmts object for local admin check ...", 0) $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\") If IsObj($objWMIService) = 0 Then _MCUpgradeLogging(-1, "WARNING: Could not get winmgmts object for local admin check ...", 0) Else _MCUpgradeLogging(-1, "Successfully connected to WMI ...", 0) $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Group WHERE SID='S-1-5-32-544' AND LocalAccount='True'", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If (IsObj($colItems) = 0) Or ($g_eventerror = 1) Then _MCUpgradeLogging(-1, "WARNING: Could not create Win32_Group object for local admin check ...", 0) Else _MCUpgradeLogging(-1, "Successfully queried WMI ...", 0) For $objItem In $colItems $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "Domain: " & $objItem.Domain & @CRLF $Output = $Output & "LocalAccount: " & $objItem.LocalAccount & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "SID: " & $objItem.SID & @CRLF $Output = $Output & "SIDType: " & $objItem.SIDType & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF $adminGroup = $objItem.Name _MCUpgradeLogging(-1, $Output, 0) $Output = "" Next EndIf EndIf If $adminGroup <> "" Then Dim $filter[1] = ["group"] _MCUpgradeLogging(-1, "Getting WinNT object ...", 0) $colGroups = ObjGet("WinNT://.") If IsObj($colGroups) = 0 Then _MCUpgradeLogging(-1, "WARNING: Could not create >= WinNT object for local admin check ...", 0) Else $colGroups.filter = $filter $islocaladmin = 0 For $objGroup In $colGroups If $objGroup.name = $adminGroup Then _MCUpgradeLogging(-1, "INFO: found [" & $objGroup.name & "] group ...", 0) _MCUpgradeLogging(-1, " " & $objGroup.AdsPath, 0) _MCUpgradeLogging(-1, " " & $objGroup.Class, 0) _MCUpgradeLogging(-1, " " & $objGroup.Description, 0) _MCUpgradeLogging(-1, " " & $objGroup.Schema, 0) For $objUser In $objGroup.Members If $objUser.name = @UserName Then _MCUpgradeLogging(-1, "INFO: ++ admin! [" & $objUser.name & "] found ...", 0) $islocaladmin = 1 Else _MCUpgradeLogging(-1, "INFO: -- member [" & $objUser.name & "] found ...", 0) EndIf Next Else ;_MCUpgradeLogging(-1, "INFO: found [" & $objGroup.name & "] group ...", 0) EndIf Next EndIf EndIf If $ht_inifilepath = "" Then $MC_RESTORENWDRIVEMAPPINGS = "0" Else $MC_RESTORENWDRIVEMAPPINGS = IniRead($ht_inifilepath, "MCUpgrade", "RestoreNetworkDriveMappings", "0") EndIf If $ht_inifilepath = "" Then $MC_RESTORENWDRIVEMAPPING_OPTION = "0" Else $MC_RESTORENWDRIVEMAPPING_OPTION = IniRead($ht_inifilepath, "MCUpgrade", "RestoreNetworkDriveMappingsOption", "0") ; 0=restore mappings permutated by user/pw/domain, 1=current user only, 2=net use permutaded, 3=net use current user only EndIf If $ht_runcount = 1 And $MC_RESTORENWDRIVEMAPPINGS = 1 Then _MCUpgradeLogging(0, "Starting ...", 0) $MC_ISDEBUGGINGENABLED = IniRead($ht_inifilepath, "MCUpgrade", "IsDebuggingEnabled", "0") _MCUpgradeLogging(0, "Memorizing NetworkDriveMappings ...", 0) For $i = 1 To 26 $i3 = StringRight("000" & $i, 3) IniDelete($ht_inifilepath, "MCUpgrade", "NetworkDriveMapping" & $i3) Next Local $aArray = DriveGetDrive("NETWORK") If @error Then ; An error occurred when retrieving the drives. _MCUpgradeLogging(0, "ERROR: GetNetworkDriveMappings returned an error [" & @error & "] - continuing without Drive Mapping Information ...", 0) Else _MCUpgradeLogging(0, "GetNetworkDriveMappings returned ...", 0) For $i = 1 To $aArray[0] ; Show all the drives found and convert the drive letter to uppercase. _MCUpgradeLogging(0, $i & "/" & $aArray[0] & ": " & StringUpper($aArray[$i]) & " = " & DriveMapGet($aArray[$i]), 0) $i3 = StringRight("000" & $i, 3) IniWrite($ht_inifilepath, "MCUpgrade", "NetworkDriveMapping" & $i3, StringUpper($aArray[$i]) & DriveMapGet($aArray[$i])) Next EndIf _MCUpgradeLogging(0, "Switching current/working directory to [" & $currentdirectory & "] ...", 0) FileChangeDir($currentdirectory) ;if current user has admin rights If IsAdmin() = 1 Then If $MC_USE_COMSPEC = 1 Then _MCUpgradeLogging(0, "About to rerun (as current user = Admin) ..." & @LF & @ComSpec & ' /c ""' & @AutoItExe & '" "' & $runupgradeexe & '" "' & $ht_inifilepath & '" ' & $ht_runcount & '"', 0) Else _MCUpgradeLogging(0, "About to rerun (as current user = Admin) ..." & @LF & $ht_autoitexe_short & ' ' & $runupgradeexe_short & ' ' & $ht_inifilepath_short & ' ' & $ht_runcount, 0) EndIf _CloseLog() ;IniWrite($ht_inifilepath, "MCUpgrade", "SuRunAsInProgress", "") - not necessary as of 4.0.2.0 since we check for runcount If $MC_USE_COMSPEC = 1 Then $pid = Run(@ComSpec & ' /c ""' & @AutoItExe & '" "' & $runupgradeexe & '" "' & $ht_inifilepath & '" ' & $ht_runcount & '"', $currentdirectory, @SW_HIDE, 6) Else $pid = Run($ht_autoitexe_short & ' ' & $runupgradeexe_short & ' ' & $ht_inifilepath_short & ' ' & $ht_runcount, $currentdirectory, @SW_HIDE, 6) EndIf $ht_error = @error If $ht_error = 0 Then $launch_successful = 1 Else $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, "ERROR: Could not launch program as current user with Admin rights [" & $ht_error & "] - operation aborted", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) _MyExit() EndIf EndIf ;DELTACOPY? _MySuRunAsExec() ;if current user does not have admin rights ;_MCUpgradeLogging(0, "About to rerun (switching to Admin) ..." & @LF & @AutoItExe & ' "' & $runupgradeexe & '" "' & $ht_inifilepath & '" ' & $ht_runcount, 0) If $launch_successful = 0 Then If $ht_inifilepath = "" Then MySwitchToAdmin('"' & @AutoItExe & '" "' & $runupgradeexe & '" ' & $ht_runcount, $ht_autoitexe_short & ' ' & $runupgradeexe_short & ' ' & $ht_runcount, "rerun", "rerun with", "") Else MySwitchToAdmin('"' & @AutoItExe & '" "' & $runupgradeexe & '" "' & $ht_inifilepath & '" ' & $ht_runcount, $ht_autoitexe_short & ' ' & $runupgradeexe_short & ' ' & $ht_inifilepath_short & ' ' & $ht_runcount, "rerun", "rerun with", "") EndIf EndIf ElseIf $ht_runcount = 2 Or $MC_RESTORENWDRIVEMAPPINGS <> 1 Then ;_MCUpgradeLogging(0, "IsAdmin=" & IsAdmin(),0) If $ht_runcount = 2 Then _MCUpgradeLogging(0, "Rerun for RestoreNWDriveMappings detected ...", 0) Else _MCUpgradeLogging(0, "RestoreNWDriveMappings disabled - running upgrade directly ...", 0) EndIf If $MC_RESTORENWDRIVEMAPPINGS = 1 Then ;msgbox(64,"1","1") $CntMappings = 0 For $i = 1 To 999 $i3 = StringRight("000" & $i, 3) $ht_mapping = IniRead($ht_inifilepath, "MCUpgrade", "NetworkDriveMapping" & $i3, "") If $ht_mapping = "" Then ExitLoop $CntMappings = $CntMappings + 1 $ht_driveletter = StringLeft($ht_mapping, 2) $ht_share = StringRight($ht_mapping, StringLen($ht_mapping) - 2) If $MC_RESTORENWDRIVEMAPPING_OPTION = "0" Or $MC_RESTORENWDRIVEMAPPING_OPTION = "2" Then ; 0=restore mappings permutated by user/pw/domain, 1=current user only, 2=net use permutaded, 3=net use current user only For $n_username = 0 To UBound($sec_adminusernames) - 1 For $n_password = 0 To UBound($sec_adminuserpasswords) - 1 For $n_domain = 0 To UBound($sec_domains) - 1 _MCUpgradeLogging(-1, "Attempting permutated remap [" & $ht_share & "] as [" & $ht_driveletter & "]...", 0) If $MC_RESTORENWDRIVEMAPPING_OPTION = "0" Then If $sec_domains[$n_username] = @ComputerName Then $h_result = DriveMapAdd($ht_driveletter, $ht_share, 0, $sec_adminusernames[$n_username], $sec_adminuserpasswords[$n_password]) Else $h_result = DriveMapAdd($ht_driveletter, $ht_share, 0, $sec_domains[$n_username] & "\" & $sec_adminusernames[$n_username], $sec_adminuserpasswords[$n_password]) EndIf If $h_result = 1 Then _MCUpgradeLogging(-1, "Successful permutated remap [" & $ht_share & "] as [" & $ht_driveletter & "].", 0) ExitLoop 3 Else _MCUpgradeLogging(-1, "WARNING: Failed permutated remap [" & $ht_share & "] as [" & $ht_driveletter & "] (" & @error & "|" & @extended & ").", 0) EndIf Else ;$MC_RESTORENWDRIVEMAPPING_OPTION="2" $pid = RunAsWait($sec_adminusernames[$n_username], $sec_domains[$n_domain], $sec_adminuserpasswords[$n_password], $MC_LOGON_FLAG, "NET USE " & $ht_driveletter & " " & $ht_mapping & " /USER:" & $sec_domains[$n_username] & "\" & $sec_adminusernames[$n_username] & " " & $sec_adminuserpasswords[$n_password], @SW_HIDE, 6) $ht_error = @error If $ht_error = 0 Then _MCUpgradeLogging(-1, "Successful permutated net use remap [" & $ht_share & "] as [" & $ht_driveletter & "].", 0) Else _MCUpgradeLogging(-1, "WARNING: Failed permutated net use remap [" & $ht_share & "] as [" & $ht_driveletter & "] (" & @error & "|" & @extended & ").", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) EndIf EndIf Next Next Next Else _MCUpgradeLogging(-1, "Attempting current user remap [" & $ht_share & "] as [" & $ht_driveletter & "]...", 0) If $MC_RESTORENWDRIVEMAPPING_OPTION = "1" Then $h_result = DriveMapAdd($ht_driveletter, $ht_share, 0) If $h_result = 1 Then _MCUpgradeLogging(-1, "Successful current user remap [" & $ht_share & "] as [" & $ht_driveletter & "].", 0) Else _MCUpgradeLogging(-1, "WARNING: Failed current user remap [" & $ht_share & "] as [" & $ht_driveletter & "] (" & @error & "|" & @extended & ").", 0) EndIf Else ;$MC_RESTORENWDRIVEMAPPING_OPTION="3" --- VERY dangerous if this runs into password entry! $pid = RunWait("NET USE " & $ht_driveletter & " " & $ht_mapping, @SW_HIDE) $ht_error = @error If $ht_error = 0 Then _MCUpgradeLogging(-1, "Successful current user net use remap [" & $ht_share & "] as [" & $ht_driveletter & "].", 0) Else _MCUpgradeLogging(-1, "WARNING: Failed current user net use remap [" & $ht_share & "] as [" & $ht_driveletter & "] (" & @error & "|" & @extended & ").", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) EndIf EndIf EndIf Next EndIf ;DELTACOPY? _MySuRunAsExec() ;if current user has admin rights If IsAdmin() = 1 Then If $ht_inifilepath = "" Then If $MC_USE_COMSPEC = 1 Then _MCUpgradeLogging(0, "About to run (as current user = Admin) ..." & @LF & @ComSpec & ' /c "' & $runupgradeexe & '"', 0) Else _MCUpgradeLogging(0, "About to run (as current user = Admin) ..." & @LF & $runupgradeexe_short, 0) EndIf _CloseLog() If $MC_USE_COMSPEC = 1 Then $pid = Run(@ComSpec & ' /c "' & $runupgradeexe & '"', $currentdirectory, @SW_HIDE, 6) Else $pid = Run($runupgradeexe_short, $currentdirectory, @SW_HIDE, 6) EndIf Else If $MC_USE_COMSPEC = 1 Then _MCUpgradeLogging(0, "About to run (as current user = Admin) ..." & @LF & @ComSpec & ' /c ""' & $runupgradeexe & '" "' & $ht_inifilepath & '""', 0) Else _MCUpgradeLogging(0, "About to run (as current user = Admin) ..." & @LF & $runupgradeexe_short & ' ' & $ht_inifilepath_short, 0) EndIf _CloseLog() If $MC_USE_COMSPEC = 1 Then $pid = Run(@ComSpec & ' /c ""' & $runupgradeexe & '" "' & $ht_inifilepath & '""', $currentdirectory, @SW_HIDE, 6) Else $pid = Run($runupgradeexe_short & ' ' & $ht_inifilepath_short, $currentdirectory, @SW_HIDE, 6) EndIf EndIf $ht_error = @error If $ht_error = 0 Then $launch_successful = 1 _MyGetStdOutput($pid) $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, $StdOutput, 0) Else $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, "ERROR: Could not launch program as current user with Admin rights [" & $ht_error & "] - operation aborted", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) _MyExit() EndIf EndIf If $launch_successful = 0 Then ;if current user does not have admin rights If $ht_inifilepath = "" Then MySwitchToAdmin($runupgradeexe, $runupgradeexe_short, "run", "instantiate", "on first attempt") Else MySwitchToAdmin('"' & $runupgradeexe & '" "' & $ht_inifilepath & '"', $runupgradeexe_short & ' ' & $ht_inifilepath_short, "run", "instantiate", "on first attempt") EndIf EndIf Else _MCUpgradeLogging(0, "ERROR: Could not instantiate Administrative rights through rerun - operation aborted", 0) _MyExit() EndIf ;_MCUpgradeLogging(0, $launch_successful & " | " & $islocaladmin, 0) If $launch_successful = 0 And $islocaladmin = 1 Then ;do not run DELTACOPY since we've done that above already before trying to switch ;_MySuRunAsExec() _MCUpgradeLogging(0, "Attempting fallback to direct launch ...", 0) _MCUpgradeLogging(0, '"' & $runupgradeexe & '" "' & $ht_inifilepath & '"', 0) _CloseLog() If $MC_USE_COMSPEC = 1 Then $pid = Run(@ComSpec & ' /c ""' & $runupgradeexe & '" "' & $ht_inifilepath & '""', $currentdirectory, @SW_HIDE, 6) Else ;Local $pid = Run('"' & $runupgradeexe & '" "' & $ht_inifilepath & '"', $currentdirectory, @SW_HIDE) $pid = ShellExecute('"' & $runupgradeexe & '"', '"' & $ht_inifilepath & '"', $currentdirectory, "", @SW_HIDE) EndIf $ht_error = @error If $ht_error = 0 Then $launch_successful = 1 _MyGetStdOutput($pid) $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, $StdOutput, 0) Else $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, "ERROR: Could not launch program directly [" & $ht_error & "] - operation aborted", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) _MyExit() EndIf EndIf if $launch_successful=1 Then if $MC_INSTALLFINISHEDEXEC <> "" Then _MCUpgradeLogging(0, "Launching [" & $MC_INSTALLFINISHEDEXEC & "] in [" & StringLeft($MC_INSTALLFINISHEDEXEC, StringInStr($MC_INSTALLFINISHEDEXEC, "\", 0, -1)) & "]", 0) $pid = ShellExecute('"' & $MC_INSTALLFINISHEDEXEC & '"', "", StringLeft($MC_INSTALLFINISHEDEXEC, StringInStr($MC_INSTALLFINISHEDEXEC, "\", 0, -1))) EndIf EndIf ;END :-) _MyExit() Func _MCUpgradeLogging($PercentProgress, $LogString, $PromptYesNo) If $PercentProgress > 0 Then ProgressSet($PercentProgress, $LogString) EndIf If $PromptYesNo = 1 Then MsgBox(64, $ht_debugtitle, $LogString) ElseIf $MC_ISDEBUGGINGENABLED = 1 And $PercentProgress >= 0 Then MsgBox(64, $ht_debugtitle, $LogString) EndIf If $MC_LOGFILEHANDLE >= 0 Then $Date = @YEAR & "." & @MON & "." & @MDAY $Time = @HOUR & ":" & @MIN & ":" & @SEC FileWriteLine($MC_LOGFILEHANDLE, $Date & " - " & $Time & ": " & $LogString) EndIf EndFunc ;==>_MCUpgradeLogging Func _CloseLog() If $MC_LOGFILEHANDLE >= 0 Then FileClose($MC_LOGFILEHANDLE) $MC_LOGFILEHANDLE=-1 EndIf EndFunc ;==>_CloseLog Func _MyExit() if $MC_LOGFILEHANDLE = -1 Then $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(-1, "***** End of panagenda MarvelClient Upgrade Launcher *****", 0) _CloseLog() If $ht_inifilepath<>"" and ($flg_othersurunasinprogress=0 or $ht_runcount>1) Then IniDelete($ht_inifilepath, "MCUpgrade", "SuRunAsInProgress") Exit EndFunc ;==>_MyExit Func _Special_Folder($Folder) If (IsObj($objShell) = 0) Then ;no logging since error / invalid shell object is handled further up Return "" Else $objFolder = $objShell.NameSpace($Folder) If (IsObj($objFolder) = 0) Or ($g_eventerror = 1) Then _MCUpgradeLogging(-1, "WARNING: Could not get Shell.Application.NameSpace object", 0) $g_eventerror=0 Return "" Else $objFolderItem = $objFolder.Self If (IsObj($objFolderItem) = 0) Or ($g_eventerror = 1) Then _MCUpgradeLogging(-1, "WARNING: Could not get Folder.Self object", 0) $g_eventerror=0 Return "" Else Local $tempPath = $objFolderItem.Path If $tempPath <> "" And StringRight($tempPath, 1) <> "\" Then $tempPath = $tempPath & "\" Return $tempPath Endif EndIf EndIf EndFunc ;==>_Special_Folder Func _MyErrFunc($oError) _MCUpgradeLogging(-1, "err.number is: " & @TAB & $oError.number & @CRLF & _ "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ "err.description is: " & @TAB & $oError.description & @CRLF & _ "err.source is: " & @TAB & $oError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF, 0) $g_eventerror = 1 EndFunc ;==>_MyErrFunc Func _MyGetStdOutput($pid) ProcessWaitClose($pid) Local $temp_Output = "", $temp_Error = "" $StdOutput = "" While 1 $temp_read = StdoutRead($pid) $temp_Output = $temp_Output & $temp_read If @error Then ; Exit the loop if the process closes or StdoutRead returns an error. ExitLoop Else if $temp_read<>"" then $temp_Output = $temp_Output & @LF EndIf WEnd While 1 $temp_read = StderrRead($pid) $temp_Error = $temp_Error & $temp_read If @error Then ; Exit the loop if the process closes or StderrRead returns an error. ExitLoop Else if $temp_read<>"" then $temp_Error = $temp_Error & @LF EndIf WEnd if $temp_Output<>"" then $StdOutput = "Output -----------------------------------------" & @LF & $temp_Output if $temp_Error<>"" then $StdOutput = $StdOutput & "Error ------------------------------------------" & @LF & $temp_Error if $StdOutput="" then $StdOutput = "External program did not return any output -----" EndFunc ;==>_GetStdOutput Func MySwitchToAdmin($t_runparam_long, $t_runparam_short, $t_info1, $t_info2, $t_info3) if $t_info3<>"" then $t_info3 = $t_info3 & " " if $MC_PERMUTATED_LOGON=1 Then For $n_username = 0 To UBound($sec_adminusernames) - 1 For $n_password = 0 To UBound($sec_adminuserpasswords) - 1 For $n_domain = 0 To UBound($sec_domains) - 1 MySwitchToAdminLaunch($t_runparam_long, $t_runparam_short, $sec_adminusernames[$n_username], $sec_adminuserpasswords[$n_password], $sec_domains[$n_domain], $t_info1, $t_info2, $t_info3) if $launch_successful=1 then ExitLoop 3 Next Next Next Else For $n_username = 0 To UBound($sec_adminusernames) - 1 For $n_domain = 0 To UBound($sec_domains) - 1 MySwitchToAdminLaunch($t_runparam_long, $t_runparam_short, $sec_adminusernames[$n_username], $sec_adminuserpasswords[$n_username], $sec_domains[$n_domain], $t_info1, $t_info2, $t_info3) if $launch_successful=1 then ExitLoop 2 Next Next EndIf EndFunc Func MySwitchToAdminLaunch($t_runparam_long, $t_runparam_short, $sec_adminusername, $sec_adminuserpassword, $sec_domain, $t_info1, $t_info2, $t_info3) If $launch_successful = 0 Then If $MC_USE_COMSPEC = 1 Then _MCUpgradeLogging(0, "About to " & $t_info1 & " (switching to Admin) ..." & @LF & @ComSpec & ' /c "' & $t_runparam_long & '"', 0) Else _MCUpgradeLogging(0, "About to " & $t_info1 & " (switching to Admin) ..." & @LF & $t_runparam_short, 0) EndIf _CloseLog() If $MC_USE_COMSPEC = 1 Then $pid = RunAs($sec_adminusername, $sec_domain, $sec_adminuserpassword, $MC_LOGON_FLAG, @ComSpec & ' /c "' & $t_runparam_long & '"', $currentdirectory, @SW_HIDE, 6) Else $pid = RunAs($sec_adminusername, $sec_domain, $sec_adminuserpassword, $MC_LOGON_FLAG, $t_runparam_short, $currentdirectory, @SW_HIDE, 6) EndIf $ht_error = @error If $ht_error = 0 Then $launch_successful = 1 _MyGetStdOutput($pid) $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, $StdOutput, 0) Else $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) If $islocaladmin = -1 Then _MCUpgradeLogging(0, "ERROR: Could not " & $t_info2 & " Administrative rights " & $t_info3 & "[" & $ht_error & "] - also could not determine whether user is local admin; operation aborted", 0) ElseIf $islocaladmin = 0 Then _MCUpgradeLogging(0, "ERROR: Could not " & $t_info2 & " Administrative rights " & $t_info3 & "[" & $ht_error & "] - also user was NOT found to be a local admin; operation aborted", 0) Else _MCUpgradeLogging(0, "ERROR: Could not " & $t_info2 & " Administrative rights " & $t_info3 & "[" & $ht_error & "] - however, user was found to be a local admin --> will attempt fallback to direct launch ...", 0) EndIf _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) EndIf EndIf EndFunc Func MyIniRead($myht_inifilepath, $myht_section, $myht_key, $myht_default) $iniReadSection = IniReadSection($myht_inifilepath, $myht_section) For $i = 1 To $iniReadSection[0][0] If $iniReadSection[$i][0] = $myht_key Then Return $iniReadSection[$i][1] ExitLoop EndIf Next Return $myht_default EndFunc ;==>MyIniRead Func _MySuRunAsExec() if $MC_SOURCEDIRECTORY="" or $MC_TARGETDIRECTORY="" Then _MCUpgradeLogging(-1, "----------------------------", 0) _MCUpgradeLogging(-1, "Old or new data directory not specified; DeltaCopyNotesDataIfOnNWDrive irrelevant", 0) _MCUpgradeLogging(-1, "----------------------------", 0) ElseIf IniRead($ht_inifilepath, "MCUpgrade", "DeltaCopyNotesDataIfOnNWDrive", "") <> 1 Then _MCUpgradeLogging(-1, "----------------------------", 0) _MCUpgradeLogging(-1, "DeltaCopyNotesDataIfOnNWDrive not set", 0) _MCUpgradeLogging(-1, "----------------------------", 0) Else if StringLower(DriveGetType(StringLeft($MC_SOURCEDIRECTORY,3))) = "network" Then if not fileexists($currentdirectory & "\MCDeltaCopy.exe") Then _MCUpgradeLogging(-1, "WARNING: Could not find [" & $currentdirectory & "\MCShutdown.exe] - could not copy data directory ...", 0) Else _MCUpgradeLogging(-1, "Running DeltaCopy [" & $currentdirectory & "\MCDeltaCopy.exe] with params [" & '"' & $ht_inifilepath & '" "' & $MC_SOURCEDIRECTORY & '" "' & $MC_TARGETDIRECTORY & '"]', 0) _CloseLog() $pid = ShellExecute($currentdirectory & "\MCDeltaCopy.exe", '"' & $ht_inifilepath & '" "' & $MC_SOURCEDIRECTORY & '" "' & $MC_TARGETDIRECTORY & '"', $currentdirectory, "", @SW_HIDE) $ht_error = @error If $ht_error = 0 Then _MyGetStdOutput($pid) $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, $StdOutput, 0) _MCUpgradeLogging(-1, "MCDeltaCopy run was successful; setting SkipNotesDataDirectoryMigration=1", 0) IniWrite($ht_inifilepath, "MCUpgrade", "SkipNotesDataDirectoryMigration", "1") Else $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, "ERROR: Could not launch program [" & $ht_error & "]", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) EndIf EndIf Else _MCUpgradeLogging(-1, "Old Data directory is not on a network drive (DriveType=" & DriveGetType(StringLeft($MC_SOURCEDIRECTORY,3)) & ")", 0) EndIf EndIf If (MyIniRead($ht_inifilepath, "MCUpgrade", "SuRunAsExec001", "") = "") Then _MCUpgradeLogging(-1, "----------------------------", 0) _MCUpgradeLogging(-1, "SuRunAsExec NOT SPECIFIED", 0) _MCUpgradeLogging(-1, "----------------------------", 0) Else For $i = 1 To 999 $i3 = StringRight("000" & $i, 3) AutoItSetOption("ExpandEnvStrings", 1) $ht_exec = MyIniRead($ht_inifilepath, "MCUpgrade", "SuRunAsExec" & $i3, "") $ht_params = MyIniRead($ht_inifilepath, "MCUpgrade", "SuRunAsExecParams" & $i3, "") AutoItSetOption("ExpandEnvStrings", 0) If $ht_exec = "" Then ExitLoop $ht_params=StringReplace($ht_params, "%MC_UPGRADEINIFILEPATH%", $ht_inifilepath) $ht_params=StringReplace($ht_params, "%MC_SOURCEDIRECTORY%", $MC_SOURCEDIRECTORY) $ht_params=StringReplace($ht_params, "%MC_TARGETDIRECTORY%", $MC_TARGETDIRECTORY) if $ht_params<>"" Then _MCUpgradeLogging(-1, "Running [" & $ht_exec & "] without params ...", 0) Else _MCUpgradeLogging(-1, "Running [" & $ht_exec & "] with params [" & $ht_params & "] ...", 0) EndIf _CloseLog() $pid = ShellExecute($ht_exec, $ht_params, $currentdirectory, "", @SW_HIDE) $ht_error = @error If $ht_error = 0 Then _MyGetStdOutput($pid) $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, $StdOutput, 0) Else $MC_LOGFILEHANDLE=FileOpen($MC_UPGRADELOGFILE, 1) _MCUpgradeLogging(0, "ERROR: Could not launch program [" & $ht_error & "]", 0) _MyGetStdOutput($pid) _MCUpgradeLogging(0, $StdOutput, 0) EndIf Next EndIf EndFunc #cs ---- SMTP Mailer Begin Local $s_SmtpServer = "cronus.panagenda.com" Local $s_FromName = @username & " on " & @ComputerName Local $s_FromAddress = @UserName & "@panagenda.com" Local $s_ToAddress = "florian.vogler@panagenda.com" Local $s_Subject = "TestSubject" Local $as_Body[2] $as_Body[0] = "Testing the new email udf" $as_Body[1] = "Second Line" Local $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, "EHLO " & @ComputerName, -1) Local $err = @error If $Response = 1 Then MsgBox(64, "Success!", "Mail sent") Else MsgBox(64, "Error!", "Mail failed with error code " & $err) EndIf Exit #ce ---- SMTP Mailer End