Question

Locked

Logon Script

By msft ·
Hi all,

I am just currently creating a batch logon script for a SBS box. I have been able to successfully create the basic script such as the "net use" commands etc for network drives. However, my boss wants a script inside it that says "If [COMPUTERNAME] THEN do not run script". Can anybody help me write this? Thanks. It should be a Windows Batch File (i.e. runs in Command Prompt cmd.exe)

Thanks all

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Here ya go

by Churdoo In reply to Logon Script

Rem
Rem
if "%COMPUTERNAME%"=="SOME_COMPUTER" goto skip
Rem
Rem do stuff here
Rem
:skip
Rem skips down to here
:end


Or you may want to look into using Group Policy to assign the login scripts to computer objects by OU, and you can assign different scripts to different computers based on their OU placement.
--C

Collapse -

If you don't want to get into GPOs

by neilb@uk In reply to Logon Script

and have more than one computer that doesn't want a Login script, put those computer names in a file, one per line, and use the following bit of batch file logic. The batch file will read through the computer names file and if it finds the local machine, will exit.
[pre]
@echo off
For /F %%i in (\\pathtofile\computers.txt) DO If "%COMPUTERNAME%"=="%%i" GOTO Exit
Rem Do your login bits here
Rem .
Rem .
:Exit
[/pre]
This will let you easily modify a central list.

Neil :)

Back to Networks Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums