Google drive

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

Google Drive Enterprise

To deploy Google Drive, you want to download the file gsync.msi. To get this file you need to know the version of gsync to work out the URL. e.g. version 1.22.9403.223 uses the URL http://dl.google.com/drive/1.22.9403.0223/gsync.msi. Note how the extra '0' has been added to '223'. If you try to use http://dl.google.com/drive/1.22.9403.223/gsync.msi you'll get page not found. This extra '0' is needed to make the last group of numbers up to a length of 4.

New versions of Google Drive are released ever two weeks or so so to save my time I run a task schedule on a PC that runs every day, sees if there's a new msi, downloads it and makes a new WPKG XML file. To do this I run a compiled Autoit script and use a template XML file.

Autoit script. Compile as an exe and run this as a Windows task. It will work out the latest version by reading [1]. It will save the msi into the directory $wpkg_path\[version number]\. The WPKG template is in the dir $wpkg_tree_file - copy of the template below the Autoit code. The template file is copied locally and the string 'VERSION_NUMBER' replaced with the real Google Driver version number. The edited template file is then copied into the live WPKG tree, in my case $wpkg_tree_file.

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=gdrive_downloaded.exe
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Change2CUI=y
#AutoIt3Wrapper_Res_Fileversion=0.0.0.26
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <iNetbios.au3>
#include <LogPrint.au3>
#include <File.au3>

;Script to look for the current version of Google Drive, look to see if we've already downloaded it onto the WPKG programs dir.  If we haven't, download it and then create an updated WPKG XML file.
;
;C. Mortimer May 2015

$temp_auction_www_download = @TempDir & "\gdrive_info.html"
$get_www_tech_page = "http://www.filehippo.com/download_google_drive/tech/"
$get_www_msi_page = "http://dl.google.com/drive/"
$msi_www_filename = "gsync.msi"
$netbios_domain = "\\" & _GetNetBIOS("samba server")
$wpkg_path = $netbios_domain & "\wpkg7\server\wpkg\programs\cloud\google_drive\"
$logfile = EnvGet("temp") & "\" & @ScriptName & ".log"
$xml_template = @ScriptDir & "\google_drive_template.xml"
$replace_string = "VERSION_NUMBER"
$wpkg_tree_file = $netbios_domain & "\wpkg7\server\WPKG\packages\google_drive.xml"
$temp_copy_2_wpkg_tree = 0
$temp_copy_2_wpkg_tst_tree = 0

_logPrint($logfile, "***************************************************")
_logPrint($logfile, "------------- " & @ScriptName & " v" & FileGetVersion(@ScriptName) & " Started -------------")
_logPrint($logfile, "***************************************************")

_logPrint($logfile, "$temp_auction_www_download = " & $temp_auction_www_download)
_logPrint($logfile, "$get_www_tech_page = " & $get_www_tech_page)
_logPrint($logfile, "$get_www_msi_page = " & $get_www_msi_page)
_logPrint($logfile, "$msi_www_filename = " & $msi_www_filename)
_logPrint($logfile, "$wpkg_path = " & $wpkg_path)

Local $get_gdrive_tech_www = InetGet($get_www_tech_page, $temp_auction_www_download, 1, 1)
Do
	Sleep(250)
Until InetGetInfo($get_gdrive_tech_www, 2) ; Check if the download is complete.
Local $aData = InetGetInfo($get_gdrive_tech_www)
InetClose($get_gdrive_tech_www) ; Close the handle to release resourcs.

If $aData[3] = "True" Then
	Sleep(500)
	$a_downloaded_html = FileReadToArray($temp_auction_www_download) ; create an array containing the download WWW file
;~ 	_ArrayDisplay ($a_downloaded_html)
	$a_opening_indexes = _ArrayFindAll($a_downloaded_html, "<div class=""program-title"" title=""Google Drive ", "", "", 0, 1)
;~ 	_ArrayDisplay ($a_opening_indexes)
	For $y = 0 To UBound($a_opening_indexes) - 1 Step 1
		$version_line = StringReplace(StringReplace($a_downloaded_html[$a_opening_indexes[$y]], "<div class=""program-title"" title=""Google Drive ", ""), """>", "")
		$version_line = StringReplace($version_line, " ", "")
;~ 		ConsoleWrite("$version_line = " & $version_line & @CRLF)
		$version_line_no_dec = StringReplace($version_line, ".", "")
		If StringIsDigit($version_line_no_dec) = 1 Then
			ConsoleWrite("latest gdrive = '" & $version_line & "'" & @CRLF)
			_logPrint($logfile, "latest gdrive = '" & $version_line & "'")
			;now check to see if we have a directory on \\mathsdom\wpkg7 for this version of gdrive
			If FileExists($wpkg_path & $version_line & "\gsync.msi") = 0 Then

				;sometimes the version number can not be used for the url download if the last two groups of numbers don't have 4 characters per group i.e. 1.22.9403.223 won't work, it needs to be 1.22.9403.0223.  We need to check for this
;~ 				$version_line_www = "1.22.1103.9923"
				$version_line_www = $version_line
				$version_array = StringSplit($version_line_www, ".")
;~ 				_ArrayDisplay ($version_array)
				If StringLen($version_array[3]) <> 4 Then
					Do
						$version_array_3 = $version_array[3]
						_ArrayInsert($version_array, 3, "0" & $version_array_3)
;~ 						_ArrayDisplay ($version_array)
						_ArrayDelete($version_array, 4)
;~ 						_ArrayDisplay ($version_array)
					Until StringLen($version_array[3]) = 4
				EndIf
;~ 				_ArrayDisplay ($version_array)
				;now check the last group of numbers
				If StringLen($version_array[4]) <> 4 Then
					Do
						$version_array_4 = $version_array[4]
						_ArrayDelete($version_array, 4)
;~ 						_ArrayDisplay ($version_array)
						_ArrayAdd($version_array, "0" & $version_array_4)
;~ 						_ArrayDisplay ($version_array)
					Until StringLen($version_array[4]) = 4
				EndIf
;~ 				_ArrayDisplay ($version_array)
				$version_line_www = _ArrayToString($version_array, ".", 1)
;~ 				ConsoleWrite("version_line = '" & $version_line & "'")
;~ 				Exit

				If FileExists($wpkg_path & $version_line) = 0 Then
					$dir_mk = DirCreate($wpkg_path & $version_line)
					ConsoleWrite("$dir_mk = " & $dir_mk & " [1=success]" & @CRLF)
					_logPrint($logfile, "$dir_mk = " & $dir_mk & " [1=success]")
				Else
					ConsoleWrite("The dir '" & $wpkg_path & $version_line & "' already exists" & @CRLF)
					_logPrint($logfile, "The dir '" & $wpkg_path & $version_line & "' already exists")
					$dir_mk = 1
				EndIf
				If $dir_mk = 1 Then

					Local $get_gdrive_msi = InetGet($get_www_msi_page & $version_line_www & "/" & $msi_www_filename, $wpkg_path & $version_line & "\" & $msi_www_filename, 1, 1)
					ConsoleWrite("$get_gdrive_msi = '" & $get_www_msi_page & $version_line_www & "/" & $msi_www_filename & "'" & @CRLF)
					_logPrint($logfile, "$get_gdrive_msi = '" & $get_www_msi_page & $version_line_www & "/" & $msi_www_filename & "'")
					Do
						Sleep(250)
					Until InetGetInfo($get_gdrive_msi, 2) ; Check if the download is complete.
					Local $aData = InetGetInfo($get_gdrive_msi)
					InetClose($get_gdrive_msi) ; Close the handle to release resourcs.

;~ 					ConsoleWrite (" $aData[3] = " &  $aData[3] & @CRLF)
					If $aData[3] = "True" Then
						If FileExists($wpkg_path & "\latest.lnk") Then FileDelete($wpkg_path & "\latest.lnk")
						$crt_shortcut = FileCreateShortcut($wpkg_path & $version_line & "\" & $msi_www_filename, $wpkg_path & "\latest.lnk")
						ConsoleWrite("GDrive downloaded to " & $wpkg_path & $version_line & "\" & @CRLF)
						_logPrint($logfile, "GDrive downloaded to " & $wpkg_path & $version_line & "\")
						ConsoleWrite("Shortcut to the latest google drive created with result '" & $crt_shortcut & "' [1=success]" & @CRLF)
						_logPrint($logfile, "Shortcut to the latest google drive created with result '" & $crt_shortcut & "' [1=success]")
						;we'll now make a new WPKG xml file
						If FileExists($xml_template) Then
							$temp_copy = FileCopy($xml_template, $xml_template_tmp, 8)
							ConsoleWrite("A copy of the template file " & $xml_template & " to " & $xml_template_tmp & " completed with '" & $temp_copy & "' [1=success]" & @CRLF)
							_logPrint($logfile, "A copy of the template file " & $xml_template & " to " & $xml_template_tmp & " completed with '" & $temp_copy & "' [1=success]")
							$replace_ver = _ReplaceStringInFile($xml_template_tmp, $replace_string, $version_line, 0, 1)
							ConsoleWrite("There were '" & $replace_ver & "' replacements of the string '" & $replace_string & "' with the version value of '" & $version_line & "' [there should be >=1]" & @CRLF)
							_logPrint($logfile, "There were '" & $replace_ver & "' replacements of the string '" & $replace_string & "' with the version value of '" & $version_line & "' [there should be >=1]")
							$temp_copy_2_wpkg_tree = FileCopy($xml_template_tmp, $wpkg_tree_file, 1)
							ConsoleWrite("A copy of the template file " & $xml_template_tmp & " to " & $wpkg_tree_file & " completed with '" & $temp_copy_2_wpkg_tree & "' [1=success]" & @CRLF)
							_logPrint($logfile, "A copy of the template file " & $xml_template_tmp & " to " & $wpkg_tree_file & " completed with '" & $temp_copy_2_wpkg_tree & "' [1=success]")
							ConsoleWrite($xml_template_tmp & " was deleted with result '" & $del_tmp_file & "' [1=success]" & @CRLF)
							_logPrint($logfile, $xml_template_tmp & " was deleted with result '" & $del_tmp_file & "' [1=success]")
						Else
							ConsoleWrite("The file '" & $xml_template & "' doesn't exist, ending" & @CRLF)
							_logPrint($logfile, "The file '" & $xml_template & "' doesn't exist, ending")
						EndIf
						$y = UBound($a_opening_indexes) - 1
					Else
						ConsoleWrite("$aData[3] didn't return 'true', it returned '" & $aData[3] & "', download not available?  Ending" & @CRLF)
						_logPrint($logfile, "$aData[3] didn't return 'true', it returned '" & $aData[3] & "', download not available?  Ending")
					EndIf
				Else
					$dir_mk = 1
					ConsoleWrite("$dir_mk <> 1 (" & $dir_mk & ") therefore ending" & @CRLF)
					_logPrint($logfile, "$dir_mk <> 1 (" & $dir_mk & ") therefore ending")
				EndIf
			Else
				ConsoleWrite($wpkg_path & $version_line & " already exists, no need to download anything" & @CRLF)
				_logPrint($logfile, $wpkg_path & $version_line & " already exists, no need to download anything")
			EndIf
		EndIf
	Next
Else
	ConsoleWrite("Failed to obtain the latest Google Drive version.  What does '" & $get_www_tech_page & "' show?" & @CRLF)
	_logPrint($logfile, "Failed to obtain the latest Google Drive version.  What does '" & $get_www_tech_page & "' show?")
EndIf
_logPrint($logfile, "***************************************************")
_logPrint($logfile, "")

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. The contents of wpkg_silent_msi_uninstall.bat and uninstall_value-master.au3 are below. The command "\\%DOMAIN%\netlogon\scripts\autoit3cmd_64.exe" is something I use to run a au3 file and view the output. 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 path to the exe file. wpkg_silent_msi_uninstall.bat would then need tweaking so to not expect 5 variables being passed to it but to expect 4, other lines will need changing too.

<?xml version="1.0" encoding="UTF-8"?>
<packages>

	<package id="googledrive" name="Google Drive" revision="%version%" reboot="false" priority="17"> 
	<variable name="VERSION" value="VERSION_NUMBER" />	 
	<check type="uninstall" condition="versionequalto" path="Google Drive" value="%VERSION%" />
	<!--<depends package-id="vc-runtime-2008" />	-->
 
	<install cmd='%COMSPEC% /c "%SOFTWARE%\cloud\google_drive\gdrive_install.bat %VERSION%' />
	<install cmd='%COMSPEC% /c if exist "%PUBLIC%\desktop\Google Docs.lnk" del /q "%PUBLIC%\desktop\Google Docs.lnk"' />
	<install cmd='%COMSPEC% /c if exist "%PUBLIC%\desktop\Google Sheets.lnk" del /q "%PUBLIC%\desktop\Google Sheets.lnk"' />
	<install cmd='%COMSPEC% /c if exist "%PUBLIC%\desktop\Google Slides.lnk" del /q "%PUBLIC%\desktop\Google Slides.lnk"' />
	
	<upgrade cmd='%COMSPEC% /c "%SOFTWARE%\cloud\google_drive\gdrive_install.bat %VERSION%' />
	<upgrade cmd='%COMSPEC% /c if exist "%PUBLIC%\desktop\Google Docs.lnk" del /q "%PUBLIC%\desktop\Google Docs.lnk"' />
	<upgrade cmd='%COMSPEC% /c if exist "%PUBLIC%\desktop\Google Sheets.lnk" del /q "%PUBLIC%\desktop\Google Sheets.lnk"' />
	<upgrade cmd='%COMSPEC% /c if exist "%PUBLIC%\desktop\Google Slides.lnk" del /q "%PUBLIC%\desktop\Google Slides.lnk"' />
	
	<remove cmd='%COMSPEC% /c if defined ProgramW6432 ("\\%DOMAIN%\netlogon\scripts\uninstall\wpkg_silent_msi_uninstall.bat" "\\%DOMAIN%\netlogon\scripts\autoit3cmd_64.exe" "\\%DOMAIN%\netlogon\scripts\uninstall\uninstall_value-master.au3" "Google Drive" 1 1)' />
 
</package>

</packages>

wpkg_silent_msi_uninstall.bat

@echo off
:start
REM 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 for
REM 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=%1
set uninstall_exe=%2
set toremove=%3
set case=%4
set exact=%5
set tmpfile=%temp%\.zz.txt
set logfile=wpkg_silent_msi_uninstall
set key=
set domain=mathsdom
set counter_wu=0
set counter_wu-max=120
set 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 end
For /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 end
echo.
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 end
For /F "Tokens=1" %%j in ('\\%domain%\netlogon\bin\time_now.exe') do set time_now=%%j
echo.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 end
If errorlevel 0 echo.[%date% %time%]:  msiexec exited with error 0 >>"%temp%\%logfile%.log"&echo.msiexec exited with error 0
REM echo.Run msiexec /qn /x%key%
REM echo.[%date% %time%]:  Run msiexec /qn /x%key% >>"%temp%\%logfile%.log"
REM msiexec  /qn /x%key%


:end
If exist %tmpfile% del /q %tmpfile%
echo.Finished
echo.[%date% %time%]:  ----------------Script Finished---------------- >>"%temp%\%logfile%.log"
echo. >>"%temp%\%logfile%.log"

uninstall_value-master.au3

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=uninstall_value.exe
#AutoIt3Wrapper_Change2CUI=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include "..\autoit3\include\LogPrint.au3"

; 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 $searchfor = "", $case, $exact, $uninstallstring, $key_and_uninstallstring, $var, $regread, $numberof = 0

If Not StringInStr(@AutoItExe, "AutoIt3\autoit3") Then
	If $CmdLine[0] < 3 Then
		ConsoleWrite("Usage" & @CRLF & @CRLF & "You need to provide three arguments." & @CRLF & @CRLF & _
				"The first is the string you want to search for." & @CRLF & _
				"The second is either '1' = case sensitive search or a '0' = not case sensitive." & @CRLF & _
				"The third is either '1' = exact match or '0', a partial match." & _
				"This script sets an errorlevel equal to the number of matching uninstall values." & _
				@CRLF & @CRLF & "E.g. " & @ScriptName & " mozilla 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

;~ If StringInStr ($searchfor, "?") Then $searchfor = StringReplace ($searchfor, "?", "[:alnum:]")
;~ ConsoleWrite ("$searchfor = '" & $searchfor & "'" & @CRLF)

_logPrint($MainLog, "$case = '" & $case & "'")
_logPrint($MainLog, "$exact = '" & $exact & "'")
_logPrint($MainLog, "$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, "@OSArch = " & @OSArch)
	$parent_key = "HKLM\SOFTWARE\wow6432node\Microsoft\Windows\CurrentVersion\Uninstall"
	_regfind()
EndIf

ConsoleWrite($uninstallstring & @CRLF)
_logPrint($MainLog, "$uninstallstring = " & @CRLF & $uninstallstring)
StringReplace ($uninstallstring, "}", "}")
$numberof = @extended
_logPrint($MainLog, "number of uninstall strings = " & $numberof)
_logPrint($MainLog, "----------- " & @ScriptName & " Finished -----------")
Exit $numberof

; ======================================================== FUNCTIONS ========================================================

Func _regfind()
;~ 	ConsoleWrite("reg = " & $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 $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
				ConsoleWrite ("The string '" & $searchfor & "' is in the reg key '" & $parent_key & "\" & $var & "' (" & RegRead($parent_key & "\" & $var, "DisplayName") & ")" & @CRLF)
				_logPrint($MainLog, "The string '" & $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(RegRead($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
	Next
EndFunc   ;==>_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