?
Solved

Login script that changes based on a PC name

Posted on 2003-04-01
5
Medium Priority
?
126 Views
Last Modified: 2010-04-13
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
0
Comment
Question by:woodsman707
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Expert Comment

by:MSGeek
ID: 8247203
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
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 8247380
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
 
LVL 85

Expert Comment

by:oBdA
ID: 8247393
Do I need to tell you to remove the "echo" in front of the "net use" command to arm the script? Probably not.
0
 
LVL 9

Expert Comment

by:MSGeek
ID: 8247520
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
 

Author Comment

by:woodsman707
ID: 8249293
ok, I think I understand most of this. Thanks a lot, I appreciate it.

Justin
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question