I'm currently building up a Windows Server 2008 R2 for use as a terminal server, and I'm looking for options on scripting. I know how I can attach logon scripts to the user in Active Directory, or to all logins on the server via registry tweak, but that is not what I want here.

Ideally, I want my script to only run the first time the user logs into the terminal server, so right after their profile is created on that server. I want to set some registry keys, map network drives, that sort of thing.

Is this possible, and can you point me to how it might be done? Is it worth doing? Should I just forget this and make the script safe to run every single time a logon occurs?

2 Answers 2


You could create a GPO using the Group Policy Preferences node rather than the Policies node to create both mapped drives and registry keys. Use the "Create" action which deploys your settings only if they don't exist.

The uniqueness of Preferences is that the settings deployed subsequently are user configurable, unlike Policies which are not.

There are several ways of targeting only users logging on to the Terminal Servers. For instance you can set a Group Policy Preference target condition as part of the preference, specifying logon to the Terminal Server machines as a requirement. This mechanism does not exist in the Policies node (which uses ACLs exclusively).

Read more here.


If you really want to do it with a script you could create a file in the users profile or set a registry key within the script and check if the file or specific registry key exists.

But you could also use Group Policies for mapping network drives and configuring stuff. Would be way better since you could also add configurations later and be sure the additional settings would be applied to each user. Using a script this would get pretty complicated later on.

  • I just want these map drives and configurations to work for users on the terminal server. Not on any other computer. Can that be done via GP?
    – MAW74656
    Dec 2, 2013 at 21:44
  • Yes. You assign the policy to the computer account and enable loopback processing.
    – Rex
    Dec 2, 2013 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.