How to automatically run several .bat scripts after image deployment
-
Much of the software that is installed on our images requires licensing after deployment in order for it to work. I have made a couple of .bat scripts that will do that silently. Is there a way to have them automatically run after deployment of the image or upon logging for the first time?
I am looking for whatever solution people have found for this, whether there is some FOG feature that will do this or some workaround in Windows itself.
Thanks in advance!
-
There are a number of ways you can go about this. One method is with fog and the other method is with windows.
- FOG Method: Create a batch file snap-in a attach the snap-in to a FOG group.
- Windows Method(s):
a) add the batch commands to the setupcomplete.cmd file before you capture the image. The setupcomplete.cmd batch file is run at the end of OOBE and just before the login is displayed.
b) Add the batch commands to the unattend.xml in the first run section. Then configure auto admin login for a login count of 1. Setup the last first run sequences to shutdown / reboot / after 15 seconds / while displaying “this computer will reboot in 15 seconds”
-
Thanks for the reply! I’m going to get working on these.
-
@mecsr Use powershell instead of bat scripts, you’ll have more power. Pun intended, but it’s also just true. Especially when it comes to licensing tools. Sometimes the tools just don’t have command line options. Powershell has more user friendly tools for editing registry keys and environemnet variables which licenses sometimes require.
Also use the windows system image manager included in the windows ADK for creating an unattend.xml file
Snapins are an excellent method.
-
I learned scripting when I was 13, I used DOS from floppy disks because my computer’s hard drive failed and didn’t work… and I self-taught myself using a DOS for Dummies book from the public library. That was about 18 years ago and it was obsolete then… Now I cringe when I think about bat files. Python, please and thank you.
-
I suppose, to answer the question more directly, you can do a snapin pack.
Create a base batch file, and all your others. Create them into a zip file. Your “base” batch file would simply call the other batch files as required.
For example, you create a snapin pack with licensing.zip as the base name.
Inside licensing.bat you would, essentially, have:
@echo off %~dp0\license1.bat %~dp0\license2.bat %~dp0\license3.bat %~dp0\license4.bat %~dp0\license5.bat %~dp0\license6.bat %~dp0\license7.bat %~dp0\license8.bat %~dp0\license9.bat %~dp0\license10.bat %~dp0\license11.bat %~dp0\license12.bat %~dp0\license13.bat
(Some of the syntax may be off, but the idea is the same. For what it’s worth, the
%~dp0
is windows slang for, the current drive and path of the running script, this way you don’t have to hardcode the path to find these other files.)