3

Do Logon Scripts set via Group Policy (User Configuration\Windows Settings\Scripts (Logon/Logoff)) run concurrently or one after the other?

The reason I ask is because I'm unsure whether it would be best to have one larger script that contains all my required actions, or several smaller scripts.

The TechNet docs tell you how to set them, but not how they are run.

1
  • or several smaller scripts - Go with smaller scripts. If you have to make a change to a single large script you might break your entire login process. Making an edit to one small script won't break everything if it is wrong, and your scripts will be easier to work with since they will be small and focused. On modern systems the difference would probably be fractions of a second depending on what you are doing in your script.
    – Zoredache
    Nov 20, 2013 at 17:33

2 Answers 2

2

Logon scripts run concurrently.

The documentation you linked to suggests that scripts are run consecutively "processed in [...] order":

If you assign multiple scripts, the scripts are processed in the order that you specify. To move a script up in the list, click it, and then click Up. To move a script down in the list, click it, and then click Down.

The documentation is not clear on what "processed in [...] order" means, so I put together a little test. I wrote two scripts that log an event, sleep for five seconds, log another event and quit:

Set sh = WScript.CreateObject("WScript.Shell")
sh.LogEvent INFORMATION, "Hello from Script A"
WScript.Sleep 5000
sh.LogEvent INFORMATION, "Goodbye from Script A"

The other script is identical except the log messages say "Script B" instead.

I put both of these scripts on a GPO as logon scripts and applied the GPO. After policy refreshed and I logged on to the test computer, I checked the Event Viewer.

The result was that "Hello from Script A" and "Hello from Script B" were logged at the same time. Five seconds later, "Goodbye from Script A" and "Goodbye from Script B" were logged at the same time.

To be precise, the log entries were added in the same second, and the time resolution for these entries does not get into fractions of a second, so I am not sure which script wrote to the log first. Event viewer actually shows the logs from Script B before the logs from Script A, even though the timestamps are identical.

The verdict from this simple test:

Logon scripts run concurrently.

3
  • It does indeed say that, but it doesn't specify whether it waits until one script has finished processing before moving on to the next, only that it begins processing them in that order. Thanks.
    – David Gard
    Nov 20, 2013 at 17:06
  • Good point. I expanded my answer. Nov 20, 2013 at 17:46
  • That's a good way of testing it, thanks for taking the time to do that. And thanks for the info!
    – David Gard
    Nov 20, 2013 at 18:58
0

While .bat and .vbs logon scripts run concurrently, .ps1 powershell login scripts do not. If you have two login scripts containing "sleep 120", you can see in rsop.msc that one waits for the other to finish. Or you can check running commandlines with powershell "get-wmiobject win32_process".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .