There are many ways for a system administrator to deploy software to computers on a domain. This post describes how to create a Group Policy that will deploy a Scheduled Task to your target machines that will run a batch file to perform the installation.
You might ask why I would bother with a Scheduled Tasks and installation script when Group Policy has a native way to deploy software. Good question.
The easiest way to use Group Policy to deploy software to machines on your domain is to open up Group Policy Editor > Computer Configuration > Software Settings > Software Installation > New > Package.
I agree, this is the easiest and best way in most cases. There are some shortcomings:
- deployment is only triggered when a user reboots
- installation performs at startup, forcing a longer startup time
- the client must have network connectivity before the Ctrl-Alt-Del screen, which is difficult for wireless devices
- only .MSI files may be deployed
I work at a hospital. Our mobile carts are used by nurses, use wireless, and rarely reboot. When I use Group Policy’s Software Installation feature, they rarely receive those deployments. I needed a way for the wireless carts to receive software updates.
By creating Scheduled Task to run a simple installation script, I’m able to schedule software installations to these wireless devices. I’ll start with the installation script and then describe the Scheduled Task.
Software Deployment Installation Script
This script does the following:
- copies installation media from a networked resource (shared folder) to the client
- installs the application from the installation media now located on the client
- deletes the local installation media from the client after installation
The script also records this activity in two log files:
- a .TXT file named after the client
- a .CSV file that aggregates the installation of all clients
Here’s my script, which you may copy and save as a .BAT file.
REM Begin Script
REM Remote software installation script
REM Author: Jason Pearce of jasonpearce.com
REM Written: 2010 November 17
REM Trigger this script as a scheduled task via Group Policy
@REM INSTALL APPLICATION FROM LOCAL MEDIA
SET FRIENDLYNAME=Adobe Flash Player
REM Copy remote media to local folder
echo %DATE% %TIME% Began copying %FRIENDLYNAME% from %SOURCEFOLDER% to %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt
%SystemRoot%\system32\xcopy.exe %SOURCEFOLDER% %TARGETFOLDER% /Y /E /I /S
echo %DATE% %TIME% Finished copying %FRIENDLYNAME% from %SOURCEFOLDER% to %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt
echo %COMPUTERNAME%,%DATE%,%TIME%,%FRIENDLYNAME%,copied >>%LOGFOLDER%\InstallationLog.csv
REM Install application on client
echo %DATE% %TIME% Began installing %FRIENDLYNAME% >>%LOGFOLDER%\%COMPUTERNAME%.txt
%SystemRoot%\system32\msiexec.exe /i %TARGETFOLDER%\%SOURCEFILE% /qn
echo %DATE% %TIME% Finished installing %FRIENDLYNAME% >>%LOGFOLDER%\%COMPUTERNAME%.txt
echo %COMPUTERNAME%,%DATE%,%TIME%,%FRIENDLYNAME%,installed >>%LOGFOLDER%\InstallationLog.csv
REM Delete local installation media
echo %DATE% %TIME% Began deleting %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt
rd %TARGETFOLDER% /S /Q
echo %DATE% %TIME% Finished deleting %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt
echo %COMPUTERNAME%,%DATE%,%TIME%,%FRIENDLYNAME%,folder deleted >>%LOGFOLDER%\InstallationLog.csv
echo End Installation Script
Create and Deploy a Scheduled Task via Group Policy
The next step is to create a new Group Policy that adds a new Scheduled Task to the clients in the Organizational Units you choose to target. In my case, I created a new Group Policy and applied it to the OU that contains all of the mobile wireless carts that our nurses use.
- Open Group Policy Management
- Navigate to the Organization Unit you wish to receive software deployment via a schedule task
- Right-click on your target OU and select “Create a GPO in this domain, and Link it here”
- Name: Deploy Application via Scheduled Tasks
- Group Policy Management Editor > Computer Configuration > Preferences > Control Panel Settings > Scheduled Tasks
- Right-click on Scheduled Tasks > New > Scheduled Tasks
- Tab Tasks > Action > Create
- Tab Task > Name > Install Adobe Flash
- Tab Task > Run > \\yourserver\netlogon\scripts\install-adobe-flash.bat
- Tab Task > Enabled > checked
- Tab Schedule > Scheduled Task > Once, 2:00:00 AM
- Tab Schedule > Scheduled Task Once > Run On > Pick a day that is best for you
- (optional) Tab Settings > Power Management > Wake the computer to run this task > checked
Link this Group Policy to one or more OUs and under Security Filtering, add Authenticated Users and Domain Computers.
That should do it. In about 90 minutes, computers on your domain should have a new scheduled task that they will run only once at 2:00 am on some future date. You may then check your log folder to see their progress.