Jump to content

MarkBe

Members
  • Posts

    13
  • Joined

  • Last visited

MarkBe's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Yes, SYSTEM context. The splash text shows for some time. During file copy (third line of script), and during the first part of the installer (during the RunWait) but then goes away about 2 minutes in. p.s. shutdown scripts are set to 'run visible'
  2. I run a compiled .exe as a group policy shutdown script to update various software. The function below is called to run both .exe and .msi installers (hence the two sections). When I run this in a user session the SplashTextOn window stays visible in the background throughout the entire install but when this is executed as a shutdown script the SplashTextOn window disappears before the installer has finished (during the RunWait) Func _InstallSW() SplashTextOn("Installing", $InstallingUpdateMessage, 500, 400, -1, -1, $DLG_NOTONTOP) FileCopy ($SourcePath & $SWInstaller, $WorkingDirectory & $SWInstaller, $FC_OVERWRITE + $FC_CREATEPATH) If StringLower(StringRight($SWInstaller, 4))=".exe" Then RunWait ('"' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches) Else RunWait ('msiexec /i "' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches) EndIf SplashOff() EndFunc ;==>InstallSW Is there a better function to use or something I can add (e.g. While)? I need it to remain behind the installer's progress windows so it shows when the installer is running a background process (to prevent the user from forcing the power off thinking it has hung)
  3. definitely cleaner: Func _InstallSW() MsgBox ($MB_ICONINFORMATION, "Installing", $InstallingUpdateMessage, 3) FileCopy ($SourcePath & $SWInstaller, $WorkingDirectory & $SWInstaller, $FC_OVERWRITE + $FC_CREATEPATH) If StringLower(StringRight($SWInstaller, 4))=".exe" Then RunWait ('"' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches) Else RunWait ('msiexec /i "' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches) EndIf EndFunc ;==>InstallSW
  4. I used to run the installers from the domain share but some remote users found that the script timed out before completion I also decided to replace on copy because some users got a corrupted copy on the C:\ and so I needed the EXE to be replaced so it didn't fail repetitively! There are some awful network connections between the servers and some of my users - being addressed at the moment though :-) SplashTextOn sounds good. I haven't discovered many of the cool features of AutoIT yet ... I'm a bit of a noob! This was taken all from a RunAsWait so I needed to plug in credentials to elevate. Not sure why I used CMD ... think it was because I used to do all the grunt work with CMD and just use AutoIT to elevate. Ran into problems (x64 v x86 batch) so decided to learn AutoIT. Lastly, I have the msiexec in the function so that if, in the next software section the installer is an MSI then I can still call the same _InstallSW() function and just pipe in different variables
  5. Yes, discovered that the hard way - last time I deployed this using a batch script What I have in that section for 7Zip is #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <Misc.au3> $SoftwareName="7Zip Archiver" $SoftwareVersion="16.04" $InstallingUpdateMessage="Updating " & $SoftwareName & " to " & $SoftwareVersion & "." $EndMessage="The current version of " & $SoftwareName & " is now installed." $FailMessage=$SoftwareName & " update failed to install. Please report error to your local IT department." $UninstallingOldMessage="Uninstalling old versions of " & $SoftwareName & "." ; Paths and files (Don't forget the "\" at the end of the path)==> \\Servername\Share\ $SourcePath="\\domain\dfsroot\share\7Zip\" $WorkingDirectory="C:\InstallCache\7zip\" $x86Installer="7z1604.exe" $x64Installer="7z1604x64.exe" $SWInstaller=((@OSArch = "X86") ? $x86Installer : $x64Installer) $InstallerSwitches=" /S" _InstallSW() Func _InstallSW() MsgBox ($MB_ICONINFORMATION, "Installing", $InstallingUpdateMessage, 3) FileCopy ($SourcePath & $SWInstaller, $WorkingDirectory & $SWInstaller, $FC_OVERWRITE + $FC_CREATEPATH) If StringLower(StringRight($SWInstaller, 4))=".exe" Then RunWait (@ComSpec & ' /k START "' & $SoftwareName & ' Installer" /wait "' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches & ' && EXIT', @SystemDir, @SW_HIDE) Else RunWait ('msiexec /i "' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches, @SystemDir) EndIf EndFunc ;==>InstallSW
  6. There's probably a more elegant way to do this but I ended up with the following: #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> #include <Misc.au3> ; Here we go! ;########################################################################################################## ;Declare variables Global $RegHive86, $RegHive64, $RegKey, $RegValue, $OldVerRegHive86, $OldVerRegHive64, $OldVerRegHive86on64, $OldVerRegVerString, $OldVerRegVerValue, $OldVerUninstallStringx86, $OldVerUninstallStringx64 ; 7Zip ;########################################################################################################## _7Zip_Function() Func _7Zip_Function() ; Variables ; --------------------------------------------------------------------------------------------------------- ; Registry location and values that are checked for current software version. Don't use paths with hash values ; Ensure the x64 key is preceeded with 'HKLM64' $RegHive86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegHive64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegKey="DisplayVersion" $RegValue="16.04" ; Reg keys and values that are checked for old versions $OldVerRegHive86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2701-0920-000001000000}" $OldVerRegHive64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2702-0920-000001000000}" $OldVerRegHive86on64="HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2701-0920-000001000000}" If _RegVersionCompare($RegHive64, $RegHive86, $OldVerRegHive64, $OldVerRegHive86, $OldVerRegHive86on64, $RegKey, $RegValue) = 1 Then _UninstallOldVer() _InstallSW() EndIf EndFunc ;==>_7Zip_Function ; Functions ;########################################################################################################## Func _RegVersionCompare($sRegHive64, $sRegHive86, $sOldVerRegHive64, $sOldVerRegHive86, $sOldVerRegHive86on64, $sRegKey, $sRegValue) If Not RegRead($sRegHive64, $sRegKey) = "" Then Local $iVersionCompare = _VersionCompare(RegRead($sRegHive64, $sRegKey), $sRegValue) Switch $iVersionCompare Case 0 Return 0 Case 1 Return 0 Case -1 Return 1 EndSwitch ElseIf Not RegRead($sRegHive86, $sRegKey) = "" Then Local $iVersionCompare = _VersionCompare(RegRead($sRegHive86, $sRegKey), $sRegValue) Switch $iVersionCompare Case 0 Return 0 Case 1 Return 0 Case -1 Return 1 EndSwitch ElseIf Not RegRead($sOldVerRegHive64, $sRegKey) = "" Then Return 1 ElseIf Not RegRead($sOldVerRegHive86, $sRegKey) = "" Then Return 1 ElseIf Not RegRead($sOldVerRegHive86on64, $sRegKey) = "" Then Return 1 Else Return 0 EndIf EndFunc ;==>_RegVersionCompare
  7. Thanks Subz You have pointed me in the right direction. Unfortunately the old version of 7Zip I am updating stores the version in a different hive ... I'll try and fix this new development myself and post back if I get stuck again Now I just need to work out how to mark your reply as the answer ...
  8. Thanks Subz This is very close. Once I had put in #include <Misc.au3> it runs the installer if the software is out of date and does not run the installer if it is current. There is one scenario that isn't working quite right for me yet, if the software isn't installed at all, I don't want the installer to run. Do you have a suggestion for handling that? Thanks p.s. I like the fact that if someone has manually installed a newer version that the script you suggested doesn't roll it back
  9. Hi I am trying to check a number of applications are up to date and install the update if required. This will run as a shutdown script, pushed out through Group Policy. I am querying various registry keys to determine if The software is actually installed The software is at the correct version Once the need for update is determined then it calls another function to run the update. If the software is up to date or not installed, it moves down to the next software section which changes the registry key variables and calls the registry query function again I have managed to get the function for (un)installs to work but I am having trouble with the registry query function #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> ; Here we go! ;########################################################################################################## ;Declare variables Global $RegKey86, $RegKey64, $RegValueName, $RegValueData, $CheckVersion86, $CheckVersion64 ; 7Zip ;########################################################################################################## _7Zip_Function() Func _7Zip_Function() ; Registry location and values that are checked for current software version ; Ensure the x64 key is preceeded with 'HKLM64' $RegKey86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegKey64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" $RegValueName="DisplayVersion" $RegValueData="16.04" ; Excecution ; --------------------------------------------------------------------------------------------------------- If _CheckSW() = 1 Then _UninstallOldVer() _InstallSW() EndIf EndFunc ;==>_7Zip_Function ; Functions ;########################################################################################################## Func _CheckSW() $CheckVersion86=RegRead ($RegKey86, $RegValueName) $CheckVersion64=RegRead ($RegKey64, $RegValueName) If $CheckVersion86=$RegValueData Or $CheckVersion64=$RegValueData Then Return 0 ElseIf $CheckVersion86="" And $CheckVersion64="" Then Return 0 Else Return 1 EndIf EndFunc ;==>CheckSW
  10. Managed to get this working. copied to local drive, then used Comspec to run the installer #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #include <FileConstants.au3> ;########################################################################################################## ; 7-Zip installation script ; Author : Mark Beaven ;########################################################################################################## ;Variables ; --------------------------------------------------------------------------------------------------------- Local $SoftwareName="7-Zip" ; Error messages (shouldn't need to alter these) Local $UninstallingOldMessage="Uninstalling old versions of " & $SoftwareName & "." Local $AlreadyInstalledMessage=$SoftwareName & " is already the current version." Local $InstallingNewMessage="Installing " & $SoftwareName & "." Local $EndMessage=$SoftwareName & " is now installed. Click 'OK' to close this window." Local $FailMessage=$SoftwareName & " failed to install. Please report error to your local IT department." ; Source path (Don't forget the "\" at the end of the path)==> \\Servername\Share\ Local $SourcePath="\\Servername\Share\7Zip\" Local $WorkingDirectory="C:\InstallCache\7zip\" Local $x86Installer="7z1604.exe" Local $x64Installer="7z1604x64.exe" Local $InstallerSwitches=" /S" ; Registry location and values that are checked for current software version. Don't use paths with hash values ; Ensure the x64 key is preceeded with 'HKLM64' Local $RegKey86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" Local $RegKey64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\7-Zip" Local $RegValueName="DisplayVersion" Local $RegValueData="16.04" ; Reg keys and values that are checked for old versions Local $920RegKey86="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2701-0920-000001000000}" Local $920RegKey64="HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2702-0920-000001000000}" Local $920RegKey86on64="HKLM64\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{23170F69-40C1-2701-0920-000001000000}" Local $920RegVerString="DisplayVersion" Local $920RegVerValue="9.20.00.0" ;Uninstall strings Local $920UninstallStringx86="MsiExec.exe /X{23170F69-40C1-2701-0920-000001000000} /qb- /norestart" Local $920UninstallStringx64="MsiExec.exe /X{23170F69-40C1-2702-0920-000001000000} /qb- /norestart" ; Variables to set to NUL Local $CheckVersion86="" Local $CheckVersion64="" Local $CheckVersion86on64="" ;Credentials ; --------------------------------------------------------------------------------------------------------- Local $USERNAME="AdminUser" Local $PASSWORD="AdminPWD" Local $DOMAIN="Domain" ;########################################################################################################## ; Excecution ;########################################################################################################## ; Check for and uninstall old versions Local $CheckVersion86=RegRead ($920RegKey86, $920RegVerString) Local $CheckVersion64=RegRead ($920RegKey64, $920RegVerString) Local $CheckVersion86on64=RegRead ($920RegKey86on64, $920RegVerString) If $CheckVersion86=$920RegVerValue Or $CheckVersion86on64=$920RegVerValue Then MsgBox ($MB_ICONWARNING, "Uninstalling", $UninstallingOldMessage, 3) RunAsWait ($USERNAME, $DOMAIN, $PASSWORD, $RUN_LOGON_NOPROFILE,$920UninstallStringx86, @SystemDir) EndIf If $CheckVersion64=$920RegVerValue Then MsgBox ($MB_ICONWARNING, "Uninstalling", $UninstallingOldMessage, 3) RunAsWait ($USERNAME, $DOMAIN, $PASSWORD, $RUN_LOGON_NOPROFILE,$920UninstallStringx64, @SystemDir) EndIf ; Variables to set to NUL (again) Local $CheckVersion86="" Local $CheckVersion64="" ; Check existing version of Software Local $CheckVersion86=RegRead ($RegKey86, $RegValueName) Local $CheckVersion64=RegRead ($RegKey64, $RegValueName) If $CheckVersion86=$RegValueData Or $CheckVersion64=$RegValueData Then MsgBox ($MB_ICONWARNING, "Installation aborted", $AlreadyInstalledMessage) Exit EndIf ; Installation of software. Calls the EXE with elevated rights Local $SWInstaller=((@OSArch = "X86") ? $x86Installer : $x64Installer) MsgBox ($MB_ICONINFORMATION, "Installing", $InstallingNewMessage, 3) FileCopy ($SourcePath & $SWInstaller, $WorkingDirectory & $SWInstaller,$FC_CREATEPATH ) RunAsWait ($USERNAME, $DOMAIN, $PASSWORD, $RUN_LOGON_NOPROFILE, @ComSpec & ' /k START "' & $SoftwareName & ' Installer" /wait "' & $WorkingDirectory & $SWInstaller & '"' & $InstallerSwitches & ' && EXIT', @SystemDir, @SW_HIDE) ;Check install went OK Local $CheckVersion86=RegRead ($RegKey86, $RegValueName) Local $CheckVersion64=RegRead ($RegKey64, $RegValueName) If $CheckVersion86=$RegValueData Or $CheckVersion64=$RegValueData Then MsgBox ($MB_ICONINFORMATION, "Installation completed", $EndMessage) Else MsgBox ($MB_ICONWARNING, "Installation failed", $FailMessage) EndIf
  11. I did try your suggestion but didn't work for non-admin user. I am pushing this app out to users that don't have admin rights, hence the run-as element. Am I correct in that the #RequireAdmin tag will only allow the script to run if the user is an admin? I am also compiling the script in x86 to allow this to be run on both architectures (in case that makes a difference). Publishing the .exe through group policy .zap file so can't check for system architecture before .exe is run
  12. Thanks for the help. Rather than getting the batch to run correctly, I moved to installing the application using AutoIT rather than calling a batch script and I got most of the way done (registry checks, uninstall of old versions) except the .exe installer does not install. It pops up the "installing" window but does not get to the UAC prompt. Please can you check my syntax? #NoTrayIcon #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Local $SoftwareName="7-Zip" Local $SourcePath="\\server\7Zip\" Local $x86Installer="7z1604.exe" Local $x64Installer="7z1604-x64.exe" Local $InstallerSwitches=" /S" Local $USERNAME="User" Local $PASSWORD="Password" Local $DOMAIN="OurDomain" ; Installation of software. Calls the EXE with elevated rights Local $SWInstaller=((@OSArch = "X86") ? $x86Installer : $x64Installer) MsgBox (48, "Installing", "Installing " & $SoftwareName, 3) RunAsWait ($USERNAME, $DOMAIN, $PASSWORD, $RUN_LOGON_NOPROFILE, $SourcePath & $SWInstaller & $InstallerSwitches, @SystemDir)
  13. I am using autoIT to elevate a batch script that installs applications and patches. This needs to run on both x86 and x64 computers so I compiled the AutoIT in x86 RunAsWait ($USERNAME, $DOMAIN, $PASSWORD, $RUN_LOGON_NOPROFILE, @ComSpec & " /k " & $SourcePath & $SoftwareBatchInstaller, @SystemDir) To speed the install process the batch script that I am calling (SoftwareBatchInstaller) contains a bunch of RegCheck commands to look for the uninstall key; skips that install if found. Then it can be used to install further patches just by running the AutoIT again @ECHO off SETLOCAL enableextensions SET InstallPath=\\server\share\ SET RegApp1=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{123123-123-123-123-123123123123123} SET RegApp2=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{123123-123-123-123-123123123123456} SET FileApp1=app1.exe SET FileApp2=app2.exe :: Install App1 SET RegCheck=%RegApp1% SET InstallFile=%FileApp1% CALL :InstallSW :: Install App2 SET RegCheck=%RegApp2% SET InstallFile=%FileApp2% CALL :InstallSW EXIT :InstallSW REG QUERY %RegCheck% >nul 2>nul IF NOT ERRORLEVEL 1 (EXIT /B) ECHO. ECHO Installing %InstallFile% START "%InstallFile%" /wait "%InstallPath%%InstallFile%" /s /v"/qn /norestart" EXIT /B The trouble I am having is that the batch script runs correctly when elevated on a x64 machine but when called from the AutoIT the RegCheck does not find the keys it's looking for so runs the install again of software that is already installed Any ideas on a better way to do this? Am I missing a switch on the @ComSpec that will run the batch as is rather than "converting" it to x64?
×
×
  • Create New...