Changes

Jump to: navigation, search

Google drive

11,309 bytes added, 12:56, 4 June 2015
Google Drive Enterprise
'''XML template file'''
Note. The 'Remove' line uses a script I use to work out the MSI uninstall command and then run it. As the command changes for each version of Google Drive a different way of working out the uninstall command is needed. Another piece The contents of Autoit code wpkg_silent_msi_uninstall.bat and uninstall_value-master.au3 are below the template can be compiled as a . The command line "\\%DOMAIN%\netlogon\scripts\autoit3cmd_64.exe" is something I use to run a au3 file and view the output. This will print There's nothing wrong with compiling uninstall_value-master.au3 and replacing '"\\%DOMAIN%\netlogon\scripts\autoit3cmd_64.exe" "\\%DOMAIN%\netlogon\scripts\uninstall\uninstall_value-master.au3"' with the msi code, this can then be put into path to the template exe file as something like this:. wpkg_silent_msi_uninstall.bat would then need teaking to not expect 5 variables being passed to it but to expect 4. wpkg_silent_msi_uninstall.bat will need playing with when using a exe.
<source lang="xml">
</source>
'''MSI Uninstall commandwpkg_silent_msi_uninstall.bat'''
<pre>
@echo off:startREM This little batch file requires 6 arguments:REM 1 - the path to autoit3cmd_[64 32].exe.exe. REM 2 - the path to uninstall_value-master.au3. REM 3 - the text of the program you want to find the uninstall data forREM 4 - if you want to search for this text case sesative or not, 0=not. REM 5 - partial or exact match The output is then passed to 'msiexec /qn' REM C. Mortimer June 2011 set autoitcmd_exe=%1set uninstall_exe=%2set toremove=%3set case=%4set exact=%5set tmpfile=%temp%\.zz.txtset logfile=wpkg_silent_msi_uninstallset key=set domain=mathsdomset counter_wu=0set counter_wu-max=120set wait-time_wu=30 echo.echo.------------------------echo.autoitcmd_exe=%autoitcmd_exe%echo.uninstall_exe=%uninstall_exe%echo.toremove=%toremove%echo.case=%case%echo.exact=%exact%echo.------------------------echo. echo.[%date% %time%]: ----------------Script Started---------------- >>"%temp%\%logfile%.log"echo.[%date% %time%]: autoitcmd_exe=%autoitcmd_exe% >>"%temp%\%logfile%.log"echo.[%date% %time%]: uninstall_exe=%uninstall_exe% >>"%temp%\%logfile%.log"echo.[%date% %time%]: %uninstall_exe% has a log file in the [user running %uninstall_exe%]'s temp dir >>"%temp%\%logfile%.log"echo.[%date% %time%]: toremove=%toremove% >>"%temp%\%logfile%.log"echo.[%date% %time%]: case=%case% >>"%temp%\%logfile%.log"echo.[%date% %time%]: exact=%exact% >>"%temp%\%logfile%.log" ::%uninstall_exe% exits with an errorlevel equal to the number of uninstall commands available for a given %toremove%. If there's more than 1 this script doesn't uninstall anything. Only when there's 1 value does msiexec run"%autoitcmd_exe%" "%uninstall_exe%" %toremove% %case% %exact% > %tmpfile%set numberofrepl=%errorlevel%If %numberofrepl% GTR 1 echo.MORE THAN ONE UNINSTALL VALUE (%numberofrepl%)&goto endFor /F "Tokens=*" %%i in ('type %tmpfile%') do Set key=%%i REM If "%key%"=="" echo.No uninstall command to run, variable KEY is blank, ending&echo.[%date% %time%]: No uninstall command to run, variable KEY is blank, ending >>"%temp%\%logfile%.log"&goto endecho.echo.uninstall_cmd='%key%'echo.[%date% %time%]: uninstall_cmd='%key%' >>"%temp%\%logfile%.log"echo.echo.%key%|find /i "{"|find /i "}"if errorlevel 1 echo.Uninstaller is a program, no msiexec therefor just run '%key%' &echo.[%date% %time%]: Uninstaller is a program, no msiexec therefore just run '%key%' >>"%temp%\%logfile%.log" & START "" /WAIT "%key% /S" &goto endFor /F "Tokens=1" %%j in ('\\%domain%\netlogon\bin\time_now.exe') do set time_now=%%jecho.Run msiexec /log %TEMP%\%time_now%uninstall.log /qn /x%key%echo.[%date% %time%]: Run msiexec /log %TEMP%\%time_now%uninstall.log /qn /x%key% >>"%temp%\%logfile%.log"msiexec /log %SYSTEMDRIVE%\tmp\%time_now%uninstall.log /qn /x%key%If errorlevel 1 echo.[%date% %time%]: msiexec exited with error 1 >>"%temp%\%logfile%.log"&echo.msiexec exited with error 1&goto endIf errorlevel 0 echo.[%date% %time%]: msiexec exited with error 0 >>"%temp%\%logfile%.log"&echo.msiexec exited with error 0REM echo.Run msiexec /qn /x%key%REM echo.[%date% %time%]: Run msiexec /qn /x%key% >>"%temp%\%logfile%.log"REM msiexec /qn /x%key%  :endIf exist %tmpfile% del /q %tmpfile%echo.Finishedecho.[%date% %time%]: ----------------Script Finished---------------- >>"%temp%\%logfile%.log"echo. >>"%temp%\%logfile%.log"</pre> '''uninstall_value-master.au3'''<pre>#Region region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_OutfileAutoIt3Wrapper_Outfile_x64=msi_productiduninstall_value.exe#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.7#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y#EndRegion endregion ;**** Directives created by AutoIt3Wrapper_GUI ****#include <Clipboard"..\autoit3\include\LogPrint.au3>$cmd_only = 0"
If ; Script to return back the uninstall command for a supplied program name. Either the exact name as used in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{prog name}; can be given or part of the name. Setting the argument to use exact matching to '1' will only match reg key values exactly, '0' will give partical matching; This script exits and sets an errorlevel. The value of the errorlevel equals the number of matching uninstall strings. ; C. Mortimer April 2011  $MainLog = EnvGet("temp") & "\" & @ScriptName & ".log"Dim $Cmdline[searchfor = "", $case, $exact, $uninstallstring, $key_and_uninstallstring, $var, $regread, $numberof = 0] > 0) And ( If Not StringInStr($cmdline[1]@AutoItExe, "?AutoIt3\autoit3") = 0) Then If $msi_file = $cmdlineCmdLine[10]< 3 Then $cmd_only = 1Else $msi_file = FileOpenDialog ConsoleWrite("Select the MSI file Usage" & @CRLF & @CRLF & "You need to find its Product Codeprovide three arguments.", EnvGet(& @CRLF & @CRLF & _ "SYSTEMDRIVEThe first is the string you want to search for."), & @CRLF & _ "MSI File (*The second is either '1' = case sensitive search or a '0' = not case sensitive.msi)", & @CRLF & _ "The third is either '1 + 2' = exact match or '0', a partial match."& _ ")This script sets an errorlevel equal to the number of matching uninstall values." & _ If @error Then MsgBox(4096, CRLF & @CRLF & "E.g. ", & @ScriptName & "No File(s) chosenmozilla 0"& @CRLF)
Exit
Else
_logPrint($MainLog, "***************************************************")
_logPrint($MainLog, "----------- " & @ScriptName & " Started -----------")
_logPrint($MainLog, "***************************************************")
_logPrint($MainLog, "total number of arguments = " & $CmdLine[0])
For $i = 1 To $CmdLine[0] Step 1
_logPrint($MainLog, "arg" & $i & "= " & $CmdLine[$i])
Next
For $i = 1 To ($CmdLine[0] - 2) Step 1
$searchfor = $searchfor & " " & $CmdLine[$i]
Next
Do
If StringLeft($searchfor, 1) = """" Then $searchfor = StringTrimLeft($searchfor, 1)
Until @extended = 0
Do
If StringRight($searchfor, 1) = """" Then $searchfor = StringTrimRight($searchfor, 1)
Until @extended = 0
Do
If StringLeft($searchfor, 1) = " " Then $searchfor = StringTrimLeft($searchfor, 1)
Until @extended = 0
Do
If StringRight($searchfor, 1) = " " Then $searchfor = StringTrimRight($searchfor, 1)
Until @extended = 0
$case = $CmdLine[$CmdLine[0] - 1]
$exact = $CmdLine[$CmdLine[0]]
EndIf
Else
$case = 0
$exact = 0
$searchfor = "Java 7 Update ?? (64-bit)"
EndIf
$a = DllCall;~ If StringInStr ("msi.dll", "uint", "MsiOpenPackage", "str", $msi_filesearchfor, "int*?", 0)Then $b searchfor = DllCallStringReplace ("msi.dll"$searchfor, "uint?", "MsiGetProductProperty", "int", $a[2:alnum:], "str);~ ConsoleWrite (", $searchfor = '"ProductCode& $searchfor & ", '"str", "", "dword*", 126& @CRLF)
DllCall_logPrint($MainLog, "msi.dll$case = '"& $case & "'")_logPrint($MainLog, "uint$exact = '"& $exact & "'")_logPrint($MainLog, "MsiCloseHandle$searchfor = '"& $searchfor & "'") $parent_key = "HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"$uninstallstring = ""$key_and_uninstallstring = ""$count = 0$i_max = 400_regfind();~ ConsoleWrite("now check for 64 bit" & @CRLF)If @OSArch = "X64" Then _logPrint($MainLog, "int@OSArch = "& @OSArch) $parent_key = "HKLM\SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall" _regfind()EndIf ConsoleWrite($uninstallstring & @CRLF)_logPrint($MainLog, "$a[2]uninstallstring = " & @CRLF & $uninstallstring)_ClipBoard_SetDataStringReplace ($b[3]uninstallstring, "}", "}")$numberof = @extended_logPrint($MainLog, "number of uninstall strings = " & $numberof)_logPrint($MainLog, "----------- " & @ScriptName & " Finished -----------")Exit $numberof ; ======================================================== FUNCTIONS ======================================================== Func _regfind();~ ConsoleWrite("reg = " & $b[3]parent_key & @CRLF) For $i = 1 To $i_max Step 1 $var = RegEnumKey($parent_key, $i);~ ConsoleWrite("var = " & $var & ", error = " & @error & ", $i = " & $i & @CRLF) If $cmd_only var = "" Then;~ ConsoleWrite ("Error reading the reg file, exiting" & @CRLF);~ _logPrint($MainLog, "Error reading the reg file, exiting") $i = $i_max Else If StringInStr(RegRead($parent_key & "\" & $var, "DisplayName"), $searchfor, $case) > 0 Then MsgBox ConsoleWrite (4096"The string '" & $searchfor & "' is in the reg key '" & $parent_key & "\" & $var & "' (" & RegRead($parent_key & "\" & $var, "DisplayName") & ")" & @CRLF) _logPrint($MainLog, "The string '" & $b[3] searchfor & "' is in the reg key '" & $parent_key & "\" & $var & "' (" & RegRead($parent_key & "\" & $var, "DisplayName") & ")") If $exact = 1 Then If StringLen(RegRead($parent_key & "\" & $var, "DisplayName")) = StringLen($searchfor) Then _logPrint($MainLog, "The string length of '" & RegRead($parent_key & "\" & $var, "DisplayName") & "' is the same length as $arg1 '" & $searchfor & "' (" & StringLen(RegRead($parent_key & "\" & $var, "DisplayName")) & " = " & StringLen($searchfor) & ")") $cont = 1 _logPrint($MainLog, "$cont = 1") Else $cont = 0 _logPrint($MainLog, "$cont = 0") EndIf Else $cont = 1 _logPrint($MainLog, "$cont = 1") EndIf;~ ConsoleWrite ("StringLen(" & RegRead($parent_key & "\" & $var, "DisplayName") & ") = " & StringLen(RegRead($parent_key & "\" & $var, "DisplayName")) & @CRLF );~ ConsoleWrite("StringLen(" & $searchfor & ") = " & StringLen($searchfor) & @CRLF ) _logPrint($MainLog, "StringLen(" & RegRead($parent_key & "\" & $var, "DisplayName") & ") = " & StringLen(copied to clipboardRegRead($parent_key & "\" & $var, "DisplayName"))) _logPrint($MainLog, "StringLen $arg1(" & $searchfor & ")= " & StringLen($searchfor)) If $cont = 1 Then;~ ConsoleWrite ($parent_key & "\" & $var & @CRLF);~ ConsoleWrite("regread = '" & RegRead($parent_key & "\" & $var, "DisplayName") & "'" & @CRLF) If StringLen(RegRead($parent_key & "\" & $var, "QuietUninstallString")) > 0 Then _logPrint($MainLog, "The stringlength of '" & $parent_key & "\" & $var & " -- QuietUninstallString' is > 0 therefore $regread = '" & RegRead($parent_key & "\" & $var, "QuietUninstallString") & "'");~ ConsoleWrite ("QUIETUNINSTALLSTRING" & @CRLF) $regread = RegRead($parent_key & "\" & $var, "QuietUninstallString");~ If $case = 1 Then;~ If $var = $searchfor Then _uninstalled("quiet");~ Else;~ If StringInStr($var, $searchfor) > 0 Then _uninstalled("quiet");~ EndIf _uninstalled() ElseIf StringLen(RegRead($parent_key & "\" & $var, "UninstallString")) > 0 Then _logPrint($MainLog, "The stringlength of '" & $parent_key & "\" & $var & " -- UninstallString' is > 0 therefore $regread = '" & RegRead($parent_key & "\" & $var, "UninstallString") & "'");~ ConsoleWrite ("UNINSTALLSTRING" & @CRLF) $regread = RegRead($parent_key & "\" & $var, "UninstallString");~ If $case = 1 Then;~ If $var = $searchfor Then _uninstalled();~ Else;~ ConsoleWrite ("$var = " & $var & @CRLF);~ If StringInStr($var, $searchfor) > 0 Then _uninstalled();~ EndIf _uninstalled() EndIf EndIf Else;~ ConsoleWrite ("nothing" & @CRLF) EndIf EndIf NextEndFunc ;==>_regfind Func _uninstalled() $count = $count + 1;~ ConsoleWrite ("$count = " & $count & @CRLF) If StringInStr($regread, "msiexec") Then $open_bracket = StringInStr($regread, "{") $close_bracket = StringInStr($regread, "}") $msi_string = StringMid($regread, $open_bracket, $close_bracket - $open_bracket + 1);~ ConsoleWrite("(" & $uorq & " - trimmed) (" & $count & ") (" & $open_bracket & "," & $close_bracket & ") " & $var & " = " & $msi_string & @CRLF);~ ConsoleWrite ("msiexec /x " & $msi_string & @CRLF) $uninstallstring = $msi_string & @CRLF & $uninstallstring $key_and_uninstallstring = StringReplace($parent_key, "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "") & "\" & $msi_string & @CRLF & $key_and_uninstallstring Else;~ ConsoleWrite("(" & $uorq & ") (" & $count & ") " & $var & " = " & $regread & @CRLF);~ ConsoleWrite ("$regread = " & $regread & @CRLF) $uninstallstring = $regread & @CRLF & $uninstallstring $key_and_uninstallstring = StringReplace($parent_key, "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "") & "\" & $regread & @CRLF & $key_and_uninstallstring EndIf _logPrint($MainLog, "$key_and_uninstallstring = '" & $key_and_uninstallstring & "'")EndFunc ;==>_uninstalled
</pre>
[[Category:Silent Installers]]
15
edits

Navigation menu