Discussion Locked

User Login Scripts

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to write a batch file that will check for certain conditions on a user login. I need to map drive letters and printers based on user groups in the Domain User manager. Example:

If JOHN_DOE belongs to DOMAIN_USERS
Then
net use r: \\serverA\documents
net use \\Print_Server\printerA

if John_DOE belongs to Marketing
then
net use z:\\MarketingServer\Ads
net use \\Print_Server\MarketingPrinter

If I am being too vague please let me know, and I will comment more

Thank you in advance for your assistance

9 replies

by shanghai sam

Instead of using a batch file, I suggest u try kixtart it can do exactly what u want here and more. u can download Kixtart here: http://www.kix32.com/downloads.html

here's a sample script for Kixtart of what u want to do...

if Ingroup("Domain_Users")
use r: /del
DelTree ("HKEY_CURRENT_USER\Network\R")
use r: \\serverA\documents /PERSISTENT
AddPrinterConnection("\\Print_Server\printerA")
SetDefaultPrinter ("printer")

endif

by men

I'm very weary of installing shareware software on a Production server, was kinda hoping it could be done through a regular DOS batch file..but I'm going to check it out

by joseph moore

You need the IFMEMBER.EXE tool from the Resource Kit. This tool, when used in a login script, will do what you want it to do. You can download IFMEMBER from the Microsoft web site here:
http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp
(please remove any spaces)

Now as for its use, here is an example:

if member of "group1" then goto group1
end
if member of "group2" then goto group2
end
if member of "group3" then goto group3
end
if member of "group4" then goto group4
end

:Group1
net time \\nt01 /set /yes
net use g: \\nt01\app
net use h: \\nt01\soft
net use i: \\nt01\download
net use j: \\nt01\test
end

:Group2
net time \\nt01 /set /yes
net use h: \\nt01\app
net use i: \\nt01\soft
end

:Group3
net time \\nt01 /set /yes
net use h: \\nt01\soft
net use i: \\nt01\download
net use j: \\nt01\test
end

:Group4
net time \\nt01 /set /yes
net use i: \\nt01\download
end

Hope this helps.

by joseph moore

BTW, I was on drugs when I put in the sample login script above!
Replace the "end"s with "EXIT" after each :Group# section.
And the first section should actually look like this:

ifmember "group1"
if errorlevel=1 goto group1
ifmember "group2"
if errorlevel=1 goto group2
ifmember "group3"
if errorlevel=1 goto group3
ifmember "group4"
if errorlevel=1 goto group4
EXIT

And, you have to put IFMEMBER.EXE in the Netlogon share on your PDC and BDCs.

So, to recap, here is the whole script, written correctly!

ifmember "group1"
if errorlevel=1 goto group1
ifmember "group2"
if errorlevel=1 goto group2
ifmember "group3"
if errorlevel=1 goto group3
ifmember "group4"
if errorlevel=1 goto group4
EXIT

:Group1
net time \\nt01 /set /yes
net use g: \\nt01\app
net use h: \\nt01\soft
net use i: \\nt01\download
net use j: \\nt01\test
EXIT

:Group2
net time \\nt01 /set /yes
net use h: \\nt01\app
net use i: \\nt01\soft
EXIT

:Group3
nettime \\nt01 /set /yes
net use h: \\nt01\soft
net use i: \\nt01\download
net use j: \\nt01\test
EXIT

:Group4
net time \\nt01 /set /yes
net use i: \\nt01\download
EXIT

Hope this actually helps.

by ð

Instead of using a batch file, I suggest u try kixtart it can do exactly what u want here and more. u can download Kixtart here: http://www.kix32.com/downloads.html

here's a sample script for Kixtart of what u want to do...

if Ingroup("Domain_Users")
use r: /del
DelTree ("HKEY_CURRENT_USER\Network\R")
use r: \\serverA\documents /PERSISTENT
AddPrinterConnection("\\Print_Server\printerA")
SetDefaultPrinter ("printer")

endif

This discussion is closed to new replies.