The default scripts are based upon the shutdown.exe from Windows XP and are originating from the Microsoft Windows 2000 Resource Kit. Since Windows 7, the parameters were slightly changed and with Windows 8 (8.1), new parameters were added. Although Windows XP is no longer considered to be supported, this article will nonetheless remain its focus on this version. The examples will be configured and presented within the boundaries of the K1000 appliance. The following examples are tested on functionality.
For more information regarding Offline KScript, go to page 324 of the Dell KACE K1000 Systems Management Appliance Administrator Guide and for the overview of the script variables (Token Replacement Variables), go to page 328 of the Dell KACE K1000 Systems Management Appliance Administrator Guide.
Syntax parameters:
- Windows XP: shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c "message"] [-d[u][p]:xx:yy]
- -l - Log off. This cannot be used with /m or /d options.
- -s - Shutdown the computer.
- -r - Full shutdown and restart the computer.
- -a - Abort a system shutdown. This can only be used during the time-out period.
- -f - Force running applications to close without forewarning users.
- -m \\ComputerName - Specify the target computer.
- -t xxx - Set the time-out period before shutdown to xxx seconds.
- -c - Comment on the reason for the restart or shutdown. Maximum of 512 characters allowed.
- -d - Provide the reason for the restart or shutdown. (For more info: http://www.ss64.com/nt/shutdown.html)
- Windows 7: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f] [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
- /i - Display the graphical user interface (GUI). This must be the first option.
- /g - Full shutdown and restart the computer. After the system is rebooted, restart any registered applications.
- /p - Turn off the local computer with no time-out or warning. Can be used with /d and /f options.
- /h - Hibernate the local computer. Can be used with the /f option.
- /e - Document the reason for an unexpected shutdown of a computer.
- Windows 8.1: shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/f] [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
- /o - Go to the advanced boot options menu and restart the computer. Must be used with /r option.
- /hybrid - Performs a shutdown of the computer and prepares it for fast startup. Must be used with /s option.
- Windows 10: shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f] [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
- /sg - Shutdown the computer. On the next boot, restart any registered applications.
- /fw - Combine with a shutdown option to cause the next boot to go to the firmware user interface.
- /f - Force running applications to close without forewarning users. The /f parameter is implied when a value greater than 0 is specified for the /t parameter.
- /soft - Description not provided.
Creating the reboot script
- Log in to the K1000 adminui: http://<K1000_hostname>/admin. Or, if the fast switching option is enabled, select an organization in the drop-down list in the top-right corner of the page next to the login information.
- Click Scripting. The Scripts page appears.
- In the Choose Action menu, select New. The Script Detail page appears.
- In the Configure section, specify script settings:
- Name: Reboot a Windows system - Provide a recognizable or relevant name that distinguishes it from others on the Scripts list.
- Enabled: Not checked - By not selecting this option, the script can be performed manually.
- Type: Offline KScript - Scripts that run at a scheduled time, based on the target device’s clock. These scripts can run even when target devices are not connected to the appliance, such as when devices start up or when users log in.
- Status: Production - If the script is still in testing phase, choose the Draft status.
- Description: (Optional) A brief description of the actions the script performs.
- Notes: Any additional information you want to provide.
- In the Deploy section specify deployment options:
- All Devices: Not checked - Use a IP Address to limit the deployment.
- Labels: Not selected - Leave this unselected.
- Devices: Computer Name or IP Address - To find devices, begin typing in the field.
- Select Specific Operating Systems: Not checked - Limit deployment to devices that have the specified operating systems.
- Operating Systems: Microsoft Windows - The script will run on all versions of specified operating systems.
- The Windows Run As settings are not required, since this concerns a Offline KScript.
- The Notify settings are not required, since this concerns a Offline KScript.
- In the Schedule section, specify the following option: None. The script can be manually executed or with an event.
- Select the additional option: "Allow run without a logged-in user". This configuration will allow the script to be executed in the following scenarios: a locked managed machine, a user is logged onto the managed machine or no one is logged onto the managed machine.
- For this script, no dependencies are required or needed.
- In the Tasks section, click New Task to add a task:
- No step(s) are required in the Verify section.
- In the On Success section, select one step "Launch a program..." to perform.
- Study the examples in the Command Details section in this article.
- No step(s) are required in the Remediation, On Remediation Success and On Remediation Failure sections.
- Do one of the following:
- Click Run Now to immediately execute the script, if provided, on the selected machines.
- Click Save.
Command Details
- Default (provided with the appliance): %WINDIR%\System32\cmd.exe /C shutdown -s -c "Shutdown by Administrator" -t 90 -d U:00:00
- NOTE: the -s parameter is used, which means that the machine will be shutdown.
- Directory: %WINDIR%\System32
- File: cmd.exe
- Wait for completion: checked
- Parameters: /C shutdown -s -c "Shutdown by Administrator" -t 90 -d U:00:00
- Custom (working examples - WIN7 and higher): $(KACE_SYS_DIR)\shutdown.exe /r /t 90 /f
- NOTE: the /r parameter is used, which means a restart will be performed on the machine.
- Directory: $(KACE_SYS_DIR)
- File: shutdown.exe
- Wait for completion: unchecked
- Parameters: /r /t 90 /f
- Custom (working examples - WIN7 and higher): $(KACE_SYS_DIR)\shutdown.exe /r /t 90 /f /d P:5:19
- NOTE: the /r parameter is used, which means a restart will be performed on the machine.
- Directory: $(KACE_SYS_DIR)
- File: shutdown.exe
- Wait for completion: unchecked
- Parameters: /r /t 90 /f /d P:5:19