ScriptRunner.exe

Run one or more scripts. Supplied with Windows 10 (1607+)

Syntax
      ScriptRunner
         -appvscript scriptFileName [Arguments]
            [-appvscriptRunnerParameters [-wait] [-timeout=TimeInSeconds] [-rollbackOnError]]
         -appvscript scriptFileName [Arguments]
            [-appvscriptRunnerParameters [-wait] [-timeout=TimeInSeconds] [-rollbackOnError]]
         ...

Key
   -appvscript  The script to be executed: PowerShell (.ps1), VBScript (.vbs), executable(.exe), Batch (.bat).
                Multiple scripts may be run by including multiple -appvscript options.
                ScriptRunner will run any script whose file type is associated with an application installed
                on the computer. If the associated application is missing, or the script’s file type isn't
                associated with any of the computer's applications, the script won't run.

   Arguments    Any arguments for the script being run.

   -appvscriptRunnerParameters
      -wait            Wait for this script to complete before continuing.
      -timeout         Timeout after TimeInSeconds seconds and continue.
      -rollbackOnError Rollback if the script exits with a non zero exit code.
                       If -rollbackOnError is set, then by implication -wait will also be True.

Default values for -appvscriptrunnerparameters: No wait, No timeout, No rollback on error

Every parameter must be separated by a space character.

The rollback on error is limited in its effect, if the script creates a new output file, then rollback will delete the file, but if the script updates or replaces an existing file then rollback will not revert those changes.
If a Scriptrunner command contains more than one -appvscript clause, then rollback on error may fail to work for either script.

You can use ScriptRunner in DeploymentConfig.xml, UserConfig.xml and AppxManifest.xml files (all trigger events).

Examples

Demonstrate the timeout by running a pause command:

ScriptRunner.exe -appvscript cmd "/c" "pause" -appvscriptrunnerparameters -wait -timeout=20

Run two scripts passing parameters to each (this is all one line):

ScriptRunner.exe -appvscript demoA.cmd arg1 arg2 -appvscriptrunnerparameters -wait -timeout=30 -rollbackonerror -appvscript demoB.ps1 arg3 arg4 -appvscriptrunnerparameters -wait -timeout=30 -rollbackonerror

In XML:
<MachineScripts>
 <AddPackage>
   <Path>ScriptRunner.exe>/Path>
   <Argument>
   -appvscript script1.exe arg1 arg2 –appvscriptrunnerparameters –wait –timeout=10
   -appvscript script2.vbs arg1 arg2
   -appvscript script3.cmd arg1 arg2 –appvscriptrunnerparameters –wait –timeout=30 –rollbackonerror
   </Arguments>
   <Wait timeout="40" RollbackOnError="true"/>
 </AddPackage>
</MachineScripts>>

"He can run. But he can't hide" ~ Joe Louis, 1946

Related:

START - Start a program, command or batch file.
Run a script - How to create and run a batch file.
Powershell: Run a script How to run a .ps1 script by calling PowerShell.exe
Equivalent bash command (Linux): Run a bash shell script


 
Copyright © 1999-2020 SS64.com
Some rights reserved