Skip to content

Sysprep_AddRunCommand

VB Scripting Library > OSD Scripting Library > Sysprep functions (OSD)

Sysprep_AddRunCommand(sDescription,sCommand)

Section titled “Sysprep_AddRunCommand(sDescription,sCommand)”

Adds a command to the unattend file that Windows Setup should execute once while it configures the deployed computer.
You can run any application or script accessible on the local computer or on the network.

ARGUMENT DESCRIPTION TYPE
sDescription A description for the run command, this is only used in unattend.xml String
sCommand The command that needs to be executed String

Boolean, TRUE if function completed successfully.

UNATTEND FILE COMPONENT PATH / SECTION SETTINGS PASS
Unattend.xml Microsoft-Windows-Deployment / RunSynchronous Specialize
C:\Sysprep\i386$oem$\cmdlines.txt New line in the [commands] section N/A

Typically used in the PreBootScript.wsf

  • In unattend.xml, the command is added as a RunSynchronousCommand with the next free order number, so commands run in the order you add them. The Microsoft-Windows-Deployment component must exist in the specialize pass, otherwise the function returns FALSE.
  • For sysprep.inf, the command is added to cmdlines.txt, which is created if it doesn’t exist.

The following example will add the command to enable the administrator account.

Private Function IncludeScript(sScriptFile)
'...
End Function
'Begin
bStatus=True
If bStatus Then bStatus=IncludeScript("customlib.cis")
If bStatus Then bStatus=IncludeLibrary("Capalib.cin")
If bStatus Then bStatus=IncludeLibrary("Osdlib.cin")
If bStatus Then bStatus=Job_Start("WS","Script Name","1.0","ScriptName.log","INSTALL")
If bStatus Then bStatus=OSD_Initialize()
sCmd="c:\windows\System32\cmd.exe /c net user administrator /active:yes"
sDesc="Enable Administrator Account"
If bStatus Then bStatus=Sysprep_AddRunCommand(sDesc,sCmd)
Job_End(bStatus)
'End main

Scripting Guidelines Constants Package Property Variables