Follow

Batch File Template for Deployment with GPO and AD

This batch file template is a companion to the article ​​Installing the Cloudamize Windows Agent by using a Group Policy Object and Active Directory. Use it to create the batch (.bat) file that you must place in the GPO deployment network shared folder.

  1. Copy and paste the template script into your code editor of choice. (Notepad is adequate.)
  2. Edit the values for the script variables (in bold, below).
  3. Name and save as a .BAT file.
  4. Place the BAT file in the network folder created with the instructions provided in the KB article linked above.


 

//////////   BEGIN SCRIPT   ///////////

@echo off
REM Begin Script​​​​​​
REM Remote software installation script

 
REM Trigger this script as a scheduled task via Group Policy

 
@REM INSTALL AGENT FROM LOCAL MEDIA
@echo off
setlocal EnableDelayedExpansion

 
REM Variables
SET FRIENDLYNAME=Cloudamize Agent
SET SOURCEFOLDER=<source folder path>
SET SOURCEFILE=<source file name>
SET TARGETFILE=<local path and file name>
SET LOGFOLDER=<logfolder>

 
REM Copy remote file to local folder
echo %DATE% %TIME% Began​ copying %FRIENDLYNAME% from %SOURCEFOLDER% to %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt

 
%SystemRoot%\system32\xcopy.exe %SOURCEFILE% %TARGETFOLDER% 
echo %DATE% %TIME% Finished copying %SOURCEFOLDER%\%SOURCEFILE% 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% customerkey=13e26479c659a2e3f01f23cf2d4ba4df2368688a36783dfc12c32e760208e345 /qn
echo %DATE% %TIME% Finished installing %FRIENDLYNAME% >>%LOGFOLDER%\%COMPUTERNAME%.txt
echo %COMPUTERNAME%,%DATE%,%TIME%,%FRIENDLYNAME%,installed >>%LOGFOLDER%\InstallationLog.csv

 
REM Delete local installation media
REM echo %DATE% %TIME% Began deleting %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt
REM rd %TARGETFOLDER% /S /Q
REM echo %DATE% %TIME% Finished deleting %TARGETFOLDER% >>%LOGFOLDER%\%COMPUTERNAME%.txt
REM echo %COMPUTERNAME%,%DATE%,%TIME%,%FRIENDLYNAME%,folder deleted >>%LOGFOLDER%\InstallationLog.csv

 
echo End Installation Script​

//////////   END SCRIPT   ///////////
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.