Bypassing User Account Properties Logon Scripts

Hi guys,
Hope you can help.
We are starting to get a pretty complicated Citrix Setup here at my work, and Im finding Im having to edit existing user logon scripts so that when they log on to Citrix Servers, some of the things such as mapping their network drives in their user logon scripts dont run only when they log on to Citrix Servers.

Is there any way by group policy to:

When users logon to certain machines only, dont run the user's logon script as defined in their user account properties in Active Directory, but do run them for all other machines?

This would definitely save a lot of time.

Thanks in advance.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If all of your machines are running XP or Server 2003, you could use a logon script from a group policy and do this with a WMI filter.

WMI filtering using GPMC

Create, import, export, copy, and paste WMI filters

Link a WMI filter to a Group Policy object

But it's probably easier to just check in the logon script for the computer name. If the user logs on to a terminal session, the computer name will be the name of the citrix server.
So if your logon script is in batch, this could look like that (you could obviously share parts of the logon script as well):

@echo off
if /i "%Computername%"=="YourCitrixServer" goto TSLogon

:: *** User is logging on to a workstation; regular logon script:
:: ...
goto :leave

:: *** User is logging on to a terminal server; special logon script:
:: ...
Simon336697Author Commented:
Hi oBdA!

Once again youre a legend.


If I have Citrix Servers with a naming convention of:

and so on,

Is it possible in your statement:

if /i "%Computername%"=="YourCitrixServer" goto TSLogon

to have a wildcard for certain characters


so you dont need to keep adding new lines for each new computer name?

Thank you so much for your help.

Yes, that's possible:
if /i "%Computername:~0,8%"=="TERMSERV" goto TSLogon
The %Variable:~x,y% syntax will expand to y characters, starting at position x in the variable (the first character is at position 0).
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Simon336697Author Commented:
Thanks oBdA,

So does this mean:

if /i "%Computername:~0,8%"=="TERMSERV"

will include:

down to

Sorry to be a pain here. Just a bit unsure of the variable.

If we had more than 9 TERMSERV


How would you include everything from TERMSERV01.............TERMSERVxx where xx could be 25 for example.

Youve been really helpful already, so I dont expect a response. Thanks so much oBdA!

That will cover everything that has "TERMSERV" as the first 8 characters (including TERMSERVONE, TERMSERVXYZ or TERMSERV9999).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Simon336697Author Commented:
Thanks again oBdA!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.