Link to home
Start Free TrialLog in
Avatar of iolike
iolike

asked on

Script for automating software deployment via AD group policy

I need to automate an application installtion via AD group policy.  I've already created a software distribution point by performing an administrative install on a network share.  Here's the tricky part:  

The process must check for a previous version of the application, and if detected, it must uninstall the application (I have the GUID) and reboot prior to installing the new application.  If no previous version exists, it can go ahead and proceed with the install.  Users don't have administrative rights on their computers, so both the install and uninstall must execute with elevated privileges.  (RunAs prompts for password).  Once the application is successfully installed, two addtional MSI packages must be installed (add-on components) and they must be installed in sequence.  I want the results outputed to log files on a nework share.  I have no experience with programming other than modifying other people's scripts.  How can I make this happen?  Below are my sorry attemtpts to do this with a batch file that will run as a startup login script using AD group policy.
date /t >"%USERPROFILE%\%USERNAME% on %COMPUTERNAME%.log" 2>&1
time /t >>"%USERPROFILE%\%USERNAME% on %COMPUTERNAME%.log" 2>&1
 
:CHECKGISLEGACY
REM This will check for the previous version of Arcview GIS and uninstall if found
 
if exist "C:\WINDOWS\Installer\{1F34839E-4826-4B64-B1B3-42E5AE8DEC5A}" (goto UNINSTALLGISOLD) ELSE (goto 
 
INSTALLGIS93)
 
:UNINSTALLGISOLD
REM This will uninstall the previous version of Arcview GIS
 
ECHO An older version of Arcview GIS Desktop has been detected.  Setup will uninstall this now.
ECHO Please wait...
msiexec /X {1F34839E-4826-4B64-B1B3-42E5AE8DEC5A} /forcerestart /qb-! ALLUSERS=1 REMOVE="ALL" 
 
>>"%USERPROFILE%\%USERNAME% on %COMPUTERNAME%.log" 2>&1
 
:INSTALLGIS93
REM This will install Arcview GIS Desktop 9.3
 
ECHO Installing Arcview GIS Desktop 9.3
ECHO Please wait...
Start /wait Msiexec /i \\SERVER\ArcviewGIS_9.3\setup.msi /qn /norestart >>"%USERPROFILE%\%USERNAME% on 
 
%COMPUTERNAME%.log" 2>&1
 
ECHO Installing VBAOF11.msi
ECHO Please wait...
Start /wait Msiexec /i \\SERVER\ArcviewGIS_9.3\VBA\VBAOF11.msi /qn /norestart >>"%USERPROFILE%\%USERNAME% on 
 
%COMPUTERNAME%.log" 2>&1
 
ECHO Installing VBAOF11I.msi
ECHO Please wait...
Start /wait Msiexec /i \\SERVER\ArcviewGIS_9.3\VBA\1033\VBAOF11I.msi /qn /norestart >>"%USERPROFILE%\%USERNAME% 
 
on %COMPUTERNAME%.log" 2>&1
 
copy "%USERPROFILE%\%USERNAME% on %COMPUTERNAME%.log" "\\SERVER\InstallLogs" /y
 
ECHO Installation Completed

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of theklap
theklap
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vadim Rapp
Your script looks good. What's the problem? it does not work?

But maybe script is not necessary at all. Usually, later version of software automatically upgrades the previous version, check if this not the case with yours. Next, Installer can detect by itself if reboot is necessary, so maybe you don't need to worry about it. Is this is all so, then all you need to do is assign the msi in the group policy to the users or to computers. Lastly, regarding the installation of your add-ons, you can probably resolve this by timing, i.e. assign first the product, then wait until everyone has installed it, and then assign the add-ons. Better would be to have in the installation of the add-ons a prerequisite that would abandon the installation if Arcview GIS Desktop 9.3 is not installed.
Depending on company size and sw release policies, for Windows stuff the simplest and confortable way nis Microsoft SMS.
Jose