Friday, December 12, 2008

Install Using Logon Script

Issue:
Automation of software install or upgrade using a logon batch file.

Quick:
Logon script calls batch file to remove old application and install new one.

Visual/Learning:
Looking at one of the user accounts you can see that the Logon script is pointed to a file called patches.bat

Patches.bat is located in the NETLOGON directory of the domain controller.




Patches.bat calls other modules to install and update software. In this case we will look at the module_mapcad.bat



This batch file is also in the NETLOGON directory




Below bat file listing in small text with comments in large text.
------------------

@echo off
rem remove, install or upgrade MapCAD for Land Desktop

This application depends on AutoCAD so the scripts checks to see if the acad.exe file exists. If it does the program jump to the start label otherwise it goes to the end label.

if exist "C:\Program Files\AutoCAD Civil 3D Land Desktop Companion 2008\acad.exe" goto start
goto end

Here is the start label. We next check for the existence of a text file. This file gets written to the drive if a previous install was successful. If it exists we jump to the end, otherwise we continue with the install.

:start
if exist "C:\Program Files\MapCAD\MapCAD-2008v12.05.txt" goto end

This uninstalls a previous version of the software. You can find the right key to uninstall by searching the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall for the name of the application you want to remove. Uninstall using the key name (long hexidecimal number). The -quite part of this does a silent uninstall

rem uninstall the previous version
msiexec.exe /Uninstall {B4AB209A-0493-4E11-BB16-72418BBFA9BF} -quiet



Here the new version is installed. The install files need to be place somewhere where then can be installed. In this case on the logon server.

rem install the new version
call "%logonserver%/netlogon/Mapcad/MapCAD_2008v12.05/MapCAD Suite 2008-LD v12.05 Setup.msi" /quiet /passive

After the install a text file is written as an indication to the script that it has already completed and does not need to run again on the current workstation. Also a tracking file is updated to monitor which workstations have run the script.

echo %computername% %date% %time% "2008v12.05 update" > "C:\Program Files\MapCAD\MapCAD-2008v12.05.txt"
echo 2008v12.05 update %computername% %date% %time% %username% >> \\FileSvr1\Batch-tracking\MapCAD.txt

:end

2 comments:

Bruce said...

Today,we are proud to announce the launch of the new wedding support service sell ffxi gil,packed with features sure to sell ffxi gils delight adventurers across Vana'diel looking to exchange eternal vows with their beloved!Responding to player demands for greater customization,the new service will grant brides and grooms freedom in choosing location,timing,dialogue,and sell Final Fantasy XI Gil more for their ceremony,allowing them to create a truly memorable event all their own.Information on all the features,including in-game sell ffxi gil item vendors and wedding certificates,can be found on the new wedding support site,so head on over sell ffxi gils and get started planning the wedding of your dreams sell Final Fantasy XIGil!

pkolbe said...

Nice. I'll try your script out next week. I've been wondering how one keeps from running a login install script over and over again.