Login script that changes based on a PC name

Hi,

I need to write a login script that looks at a range of PC names and skips a section in my script based on whether or not a PC name exists. Basically, I need to map a drive, but I only want to map that drive if the script is called from PCs named L4_01 to L4_32. I have another naming convention (L7) that use the same login names, and I need them to map seperate directories. any idea? also, are there any really difinitive resources on teh web for finding script examples?

Thanks,

Justin
woodsman707Asked:
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.

MSGeekCommented:
Sounds like you would be better off creating a group for your workstations, then through a group policy place the path to your script under logon script in the Logon/logoff section of the group policy.
0
oBdACommented:
Oh no, it's MSGeek with his group policy based logon scripts again ;).

Hi woodsman707,

you can put something like that that into your logon script:

=============8<------------------------------------------
@echo off
setlocal

rem ***************************************************************
rem *** Start mapping depending on computername:
for /f "tokens=1,2 delims=_" %%a in ("%ComputerName%") do (
  set Prefix=%%a
  set Number=%%b
)
if %Prefix%==L4 goto Map_L4
if %Prefix%==L7 goto Map_L7
goto Common

:Map_L4
if %Number% LSS 1 goto Common
if %Number% GTR 32 goto Common
rem *** Map the drive(s) for your L4_xx clients here:
echo net use L: \\server\l4share
goto Common

:Map_L7
if %Number% LSS 1 goto Common
if %Number% GTR 32 goto Common
rem *** Map the drive(s) for your L7_xx clients here:
echo net use L: \\server\l7share
goto Common

:Common
rem *** End mapping depending on computername
rem ***************************************************************
=============8<------------------------------------------

As for script examples, http://www.robvanderwoude.com/ has a nice collection.
0

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
oBdACommented:
Do I need to tell you to remove the "echo" in front of the "net use" command to arm the script? Probably not.
0
MSGeekCommented:
The shorter the login script the faster the login.  If you can apply a login script to a container instaed o f an entire organization, it makes things a bit more tidy.

oBda..  I do admire your scripting, I have added many to my knowledge base.
0
woodsman707Author Commented:
ok, I think I understand most of this. Thanks a lot, I appreciate it.

Justin
0
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 2000

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.