simple logon script help

wavewerx

Limp Gawd
Joined
Oct 8, 2008
Messages
284
Our logon scrip for our Windows 2k3 domain is waaaay out of date. It hasn't been updated in years and our users have gone from the 6 listed to about 30.

Network folders are currently mapped like so:
Code:
IF %USERNAME%=="user1" THEN GOTO ADMIN

:ADMIN
NET USE T: \\fileserver\PUBLIC
NET USE X: \\fileserver\PRIVATE

I'd like to have the shares mapped by what group the users are a member of. Basically I'm looking for "IF %groupname%=="admin" " sort of command. If there's an easier way to do this I'm all ears. I don't know much at all about logon scripts and haven't really found a great Google search source...
 
it can probably be done in a bat file, but we use vbscript.

Code:
If MemberOf(ObjGroupDict, "group") Then
   WSHNetwork.MapNetworkDrive "L:", "\\server\group"
End If

If MemberOf(ObjGroupDict, "management") Then
   WSHNetwork.MapNetworkDrive "I:", "\\server\management"
End If
 
Thanks. It's originally been a bat file. What will this script be in?

NInja edit - I'm sorry... how do I save the script? not as a .bat now, eh?
 
Thanks. It's originally been a bat file. What will this script be in?

what I posted would be a filename.vbs file

here's the first... 38 lines of the script, since you will need to declare variables and whatnot.

Code:
Dim WSHNetwork
Dim FSO
Dim strUserName ' Current user
Dim strUserDomain ' Current User's domain name
Dim ObjGroupDict ' Dictionary of groups to which the user belongs
On Error Resume next
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set FSO = CreateObject("Scripting.FileSystemObject")
' Wait until the user is really logged in...
'
strUserName = ""
While strUserName = ""
   WScript.Sleep 750 ' 5/10 th of a second
   strUserName = WSHNetwork.UserName

Wend
strUserDomain = WSHNetwork.UserDomain

'create object to edit registry
Set oShell = CreateObject("WScript.Shell")

' Read the user's account "Member Of" tab info across the network
' once into a dictionary object. 

Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)


'Map F and G drives all users Get
WSHNetwork.MapNetworkDrive "F:", "\\server\apps"
WSHNetwork.MapNetworkDrive "G:", "\\server\common"


If MemberOf(ObjGroupDict, "Nursing") Then
   WSHNetwork.MapNetworkDrive "L:", "\\server\nursing"
End If

If MemberOf(ObjGroupDict, "Chief") Then
   WSHNetwork.MapNetworkDrive "I:", "\\server\chief"
End If

just to give you a better idea. I'm certainly no pro at vbscript and had to do lots of searching on google to get it working correctly.
I would recommend writing vbscript in a decent programming editor; something like notepad++. It's what I use anyway, and makes it much easier to write.
 
Last edited:
Thanks for all that - would you mind citing the source to what you've found there? I can read a bit of most programming languages but I'm not sure which variables I need to edit for this one....
 
I use KIXTART with a very basic script, and it gets the job done in Win2K3. Here's an example of a logon script I currently use:

Code:
;****Drive Mappings

If InGroup ("Lab") = 1
 Use N: \\Server1\Share1
 Use X: \\Server1\Share2
Endif
If InGroup ("Staff") = 1
 Use I: \\Server1\Share3
 Use M: \\Server1\Share4
 Use X: \\Server1\Share2
Endif
If InGroup ("Teachers") = 1
 Use T: \\Server2\Share1
Endif

It might be what you're looking for.
 
Thanks for all that - would you mind citing the source to what you've found there? I can read a bit of most programming languages but I'm not sure which variables I need to edit for this one....

heh.. I wish :p
I don't bookmark those sites or anything. I just always search again if I need add/edit/delete something.
 
Back
Top