How to have a script run once on first boot

I have a Windows 7 image used to deploy with WDS. We like to install all our applications in the master image. The new Adobe CS6 suite needs to be serialized upon deployment, not in the master image.

I need to run this once upon first boot of the initial deployment. The command to run is:

AdobeSerialization.exe --tool=VolumeSerialize

I know that command works when I run it manually, I just can't get it to run automatically, once, on first boot.

We already have this script that runs and installs our AV client and a few other items: c:\Windows\Setup\Scripts\SetupComplete.cmd

I have copied AdobeSerialization.exe to c:\Windows\Setup\Scripts\ but it does not seem to run.

What's the recommended approach to running this script only once, during first boot?


Try making it into an actual script:
In notepad create the file AdobeSerialization.cmd and add the lines:

@echo off
start /d "path_to_file" AdobeSerialization.exe --tool=VolumeSerialize
del AdobeSerialization.cmd

Then move your script AdobeSerialization.cmd to C:\Windows\Setup\Scripts\

In the last line of the script the file deletes itself to prevent it from ever being run again. Alternatively you can move the script to another location if you do not want it removed from the machine by changing the last line to:

move AdobeSerialization.cmd "new_path"

Consider use of the RunOnce Registry key under the HKLM hive so it will run once for whichever user is first to log in.

http://msdn.microsoft.com/en-us/library/aa376977%28v=vs.85%29.aspx

Set this in Master image and upon first boot, your command can be executed. Windows takes care to delete the registry key.

EDIT (thanks to @guss) - RunServicesOnce (at same link as above) is run once per boot, not waiting for user to login. In cases where a user login should not be required, that key seems the right choice.