Author Topic: Create System Startup / Shutdown and User Logon / Logoff Scripts  (Read 4304 times)

0 Members and 1 Guest are viewing this topic.

Offline Nick

  • Administrator
  • Platinum Member
  • *
  • Posts: 46028
  • Karma: +1000/-0
  • Gender: Male
  • NickCS
    • http://www.facebook.com/nickcomputerservices
    • http://www.twitter.com/nickcomputer
    • Computer Chiangmai

Create System Startup / Shutdown and User Logon / Logoff Scripts

With Windows Server 2008 you can configure four types of scripts: Computer Startup Executed during startup; Computer Shutdown Executed prior to shutdown; User Logon Executed when a user logs on; and User Logoff Executed when a user logs off. Here's how to write these useful scripts.

With Windows Server 2008 you can configure four types of scripts:

Computer Startup Executed during startup
Computer Shutdown Executed prior to shutdown
User Logon Executed when a user logs on
User Logoff Executed when a user logs off

You can write scripts as command-shell batch scripts ending with the .bat or .cmd extension or as scripts that use the Windows Script Host (WSH). WSH is a feature of Windows Server 2008 that lets you use scripts written in a scripting language, such as VBScript, without needing to insert the script into a Web page. To provide a multipurpose scripting environment, WSH relies on scripting engines. A scripting engine is the component that defines the core syntax and structure of a particular scripting language.

Assigning Computer Startup and Shutdown Scripts
Computer startup and shutdown scripts are assigned as part of a group policy. In this way, all computers that are members of the site, domain, or organizational unit—or all three—execute scripts automatically when they’re booted or shut down.


To assign a computer startup or shutdown script, follow these steps:

1. For easy management, copy the scripts you want to use to the Machine\Scripts\Startup or Machine\Scripts\Shutdown folder for the related policy. Policies are stored in the %SystemRoot%\Sysvol\Domain\Policies folder on domain controllers.
2. In the GPMC, right-click the GPO for the site, domain, or organizational unit you want to work with and then select Edit. This opens the policy editor for the GPO.
3. In the Computer Configuration node, double-click the Windows Settings folder and then click Scripts.
4. To work with startup scripts, right-click Startup and then select Properties. To work with shutdown scripts, right-click Shutdown and then select Properties.
5. Click Show Files. If you copied the computer script to the correct location in the Policies folder, you should see the script.
6. Click Add to assign a script. This opens the Add A Script dialog box. In the Script Name field, type the name of the script you copied to the Machine\Scripts\Startup or the Machine\Scripts\Shutdown folder for the related policy. In the Script Parameters field, enter any command-line arguments to pass to the command-line script or parameters to pass to the scripting host for a WSH script. Repeat this step to add other scripts.
7. During startup or shutdown, scripts are executed in the order in which they’re listed in the Properties dialog box. Use the Up and Down buttons to reposition scripts as necessary.
8. If you want to edit the script name or parameters later, select the script in the Script For list and then click Edit.
9. To delete a script, select the script in the Script For list, and then click Remove.

Assigning User Logon and Logoff Scripts
You can assign user scripts in one of three ways:

-You can assign logon and logoff scripts as part of a group policy. In this way, all users who are members of the site, domain, or organizational unit—or all three—execute scripts automatically when they log on or log off.
-You can also assign logon scripts individually through the Active Directory Users And Computers console. In this way, -you can assign each user or group a separate logon script.
-You can also assign individual logon scripts as scheduled tasks. You schedule tasks using the Scheduled Task Wizard.
To assign a logon or logoff script in a group policy, follow these steps:

1. For easy management, copy the scripts you want to use to the User\Scripts\Logon or the User\Scripts\Logoff folder for the related policy. Policies are stored in the %SystemRoot%\Sysvol\Domain\Policies folder on domain controllers.
2. In the GPMC, right-click the GPO for the site, domain, or organizational unit you want to work with and then select Edit. This opens the policy editor for the GPO.
3. Double-click the Windows Settings folder in the User Configuration node and then click Scripts.
4. To work with logon scripts, right-click Logon and then select Properties. To work with logoff scripts, right-click Logoff and then select Properties.
5. Click Show Files. If you copied the user script to the correct location in the Policies folder, you should see the script.
6. Click Add to assign a script. This opens the Add A Script dialog box. In the Script Name field, type the name of the script you copied to the User\Scripts\Logon or the User\Scripts\Logoff folder for the related policy. In the Script Parameter field, enter any command-line arguments to pass to the command-line script or parameters to pass to the scripting host for a WSH script. Repeat this step to add other scripts.
7. During logon or logoff, scripts are executed in the order in which they’re listed in the Properties dialog box. Use the Up and Down buttons to reposition scripts as necessary.
8. If you want to edit the script name or parameters later, select the script in the Script For list and then click Edit.
9. To delete a script, select the script in the Script For list, and then click Remove.


From the Microsoft Press book Microsoft Windows Server 2008 Administrator’s Pocket Consultant by William R. Stanek.


credit: technet.microsoft.com


 
Share this topic...
In a forum
(BBCode)
In a site/blog
(HTML)


Related Topics

  Subject / Started by Replies Last post
0 Replies
5019 Views
Last post May 29, 2010, 01:50:32 AM
by Nick
0 Replies
4409 Views
Last post June 11, 2010, 04:44:53 PM
by Nick
0 Replies
3370 Views
Last post June 11, 2010, 05:06:58 PM
by Nick
0 Replies
2554 Views
Last post June 11, 2010, 05:15:00 PM
by Nick
0 Replies
2489 Views
Last post June 16, 2010, 06:03:20 PM
by Nick
0 Replies
3140 Views
Last post June 16, 2010, 06:04:49 PM
by Nick
0 Replies
1456 Views
Last post December 16, 2011, 01:54:51 PM
by Nick
0 Replies
1548 Views
Last post December 20, 2011, 02:33:09 PM
by Nick
0 Replies
1117 Views
Last post February 19, 2014, 08:33:40 PM
by Nick
0 Replies
1230 Views
Last post December 14, 2015, 09:40:41 PM
by pollokkaz