Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent login script running?

Status
Not open for further replies.

fissidens

Programmer
May 6, 2002
44
GB
When I log on to my network at a workstation I want a login batch file to run, which it does. But when I log in at a DC, using the same name, I would like to prevent the batch file from running (because it creates unwanted mapped drives). Is this possible?
I'm sure it's really obvious but I just can't think of a way of achieving this!
 
Attach the login script to the PC's OU but not the DC's?

Neill
 
I'd not even thought of putting all DCs into an OU, thanks very much. Still a beginner but willing to learn ...
 
DC's are already in a container of their own and shouldn't be moved.

Just apply login script to your workstation OU's rather than to site or domain.

 
Please post back if that actually works. I would think not since the GPO with the login script would be a USER configuration GPO and not a COMPUTER configuration GPO. It would be triggered based on the OU of the USER not the COMPUTER.
 
Er, I chickened out of the GP stuff in the end and just a simple test of %COMPUTERNAME% did the trick in the logon.bat file. It solved my problem anyway. Thanks for the ideas all the same.
 
Good idea, just make sure you keep the = OR list updated if somebody adds another DC.
 
What is the syntax for an =OR list please? I've drawn a blank trying to find that one. Thanks for your help.
 
I figured you would be using IF %COMPUTERNAME = x OR %COMPUTERNAME% = y etc. if you have multiple DC's.

Neill
 
When I try If %COMPUTERNAME%==X OR %COMPUTERNAME%==Y echo Match, I get an error that OR is not recognised as an internal or external command. I am not using a scripting language here only intrinsic commands in a batch file. Maybe I'm missing something. Thanks for your interest and help it really is appreciated.
 
Batch file syntax would probably need to be:

Code:
If %COMPUTERNAME%==X goto DCPASS
If %COMPUTERNAME%==Y goto DCPASS
<put commands here for non DC use>
:DCPASS

goto the label to bypass the net use commands and whatever else should not be done on the DC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top