Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


logon script

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1807
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> logon script
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 logon script - 1/9/2005 3:33:01 AM   
  briar

 

Posts: 2
Score: 0
Joined: 1/9/2005
From:
Status: offline
i'm starting to play with 2003 on a remote site i have that has to run a ms environment due to some proprietary dbase they run

the server is in ok and dns , dhcp etc are all fine -

im ok with the rights and all that kind of stuff and i want to
tie everything down with groups

i have a script configured in the gpo (simple one - cut and pasted from ms site but i get an error on line 8 saying type mismatch: "join"
line 8 is - strGroups = LCase(Join(CurrentUser.MemberOf))
i've only tried this on one pc - it's 2000 with sp4 - the home drive maps no probs

the script is

Const typing = "cn=typing"

Set wshNetwork = CreateObject("WScript.Network")
wshNetwork.MapNetworkDrive "h:", "\\nemesis\home\" & wshNetwork.UserName

Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, typing) Then

wshNetwork.MapNetworkDrive "g:", "\\nemesis\typing\"


ElseIf InStr(strGroups, FINANCE_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\FileServer\Finance\"
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\FinLaser"
wshNetWork.SetDefaultPrinter "\\PrintServer\FinLaser"

ElseIf InStr(strGroups, HUMAN_RESOURCES_GROUP) Then

wshNetwork.MapNetworkDrive "g:", "\\FileServer\Human Resources\"
wshNetwork.AddWindowsPrinterConnection "\\PrintServer\HrLaser"
wshNetWork.SetDefaultPrinter "\\PrintServer\HrLaser"

End If


obviously the other group bits will not work as i only setup the one group to try

even if you cant fix this one post how you do it - i
 
 
Post #: 1
 
 Re: logon script - 1/9/2005 4:10:23 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Here's what I Use alot of goodies in this one. Alot of stuff is rem out. But you can see that it shows if in this group run this. Can be download @

http://www.spoogenet.com/index.php?module=documents&JAS_DocumentManager_op=viewDocument&JAS_Document_id=19


'************************************************
'CREATE OBJECTS AND DEFINE VARIABLES
'************************************************
on error resume next
Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
set ofso=createobject("Scripting.filesystemobject")
Set oShell = CreateObject("Wscript.shell")
Set Sh = Wscript.CreateObject("Wscript.Shell")
strDomainName = wshNetwork.userDomain
strUser = WshNetwork.UserName
strComputerName = wshNetwork.ComputerName
strGroups = LCase(Join(CurrentUser.MemberOf))
MyUsername = Right(CurrentUser.Name, Len(CurrentUser.Name))
bForce = true
bUpdateProfile = true
CRLF = Chr(13) & Chr(10)

'************************************************
'Wait for User
'************************************************
do while strUser = ""
WScript.Sleep 500
loop

'************************************************
'DELETE Some NETWORK DRIVES
'************************************************
'WshNetwork.RemoveNetworkDrive "I:"
'************************************************
'DELETE ALL NETWORK DRIVES
'************************************************
Set Drives = WshNetwork.EnumNetworkDrives
If Drives.count = 0 then
'msgbox "There are no drive mappings at this time."
Else
For x = 0 to Drives.count-1 Step 2
wshNetwork.RemoveNetworkDrive Drives.Item(x),bForce, bUpdateProfile
Next
End If

'************************************************
'Setup Home Drive
'************************************************
adspath = "WinNT://" & strDomainName & "/" & strUser
set adsobj = getobject( adspath )
strHomeDrive = adsobj.homeDirDrive
strHomeDir = adsobj.homeDirectory
wshNetwork.MapNetworkDrive strHomeDrive, strHomeDir

'************************************************
'Map Drives By OU
'***********************************************
'msgbox(strgroups)
If InStr(strGroups, "cn=acct-main") Then
WSHNetwork.MapNetworkDrive "j:", "\\lmhmesrv01\apps"
WSHNetwork.MapNetworkDrive "g:", "\\lmhmesrv01\acct"
WSHNetwork.MapNetworkDrive "h:", "\\mbacct01\apps"
WSHNetwork.AddPrinterConnection "LPT1", "\\lmexgsrv01\R1045acc"
WSHNetwork.AddPrinterConnection "LPT2", "\\lmexgsrv01\l1actlj3"
WshNetwork.SetDefaultPrinter "RICOH Aficio 1045 PCL 5e"
End If
If InStr(strGroups, "cn=lnops") Then
WSHNetwork.MapNetworkDrive "j:", "\\lmhmesrv01\apps"
WSHNetwork.MapNetworkDrive "g:", "\\lmhmesrv01\operation"
WSHNetwork.AddPrinterConnection "LPT1", "\\lmexgsrv01\R1045ops"
WSHNetwork.AddPrinterConnection "LPT2", "\\lmexgsrv01\OPS2"
WSHNetwork.AddPrinterConnection "LPT3", "\\lmexgsrv01\OPS3"
WshNetwork.SetDefaultPrinter "RICOH Aficio 1045 PCL 5e"
End If
If InStr(strGroups, "cn=dpops") Then
WSHNetwork.MapNetworkDrive "i:", "\\lmhmesrv01\ipage"
WSHNetwork.MapNetworkDrive "j:", "\\lmhmesrv01\apps"
WSHNetwork.MapNetworkDrive "f:", "\\treev\fed$"
WSHNetwork.MapNetworkDrive "g:", "\\lmhmesrv01\operation"
WSHNetwork.MapNetworkDrive "t:", "\\lmhmesrv01\ivr$"
WSHNetwork.AddPrinterConnection "LPT1", "\\lmexgsrv01\R1045ops"
WSHNetwork.AddPrinterConnection "LPT2", "\\lmexgsrv01\OPS2"
WSHNetwork.AddPrinterConnection "LPT3", "\\lmexgsrv01\OPS3"
WshNetwork.SetDefaultPrinter "RICOH Aficio 1045 PCL 5e"
End If
If InStr(strGroups, "cn=spops") Then
WSHNetwork.MapNetworkDrive "j:", "\\lmhmesrv01\apps"
WSHNetwork.MapNetworkDrive "g:", "\\lmhmesrv01\acct"
WSHNetwork.MapNetworkDrive "h:", "\\mbapps01\apps"
WSHNetwork.MapNetworkDrive "o:", "\\lmhmesrv01\operation"
WSHNetwork.AddPrinterConnection "LPT2", "\\lmexgsrv01\R1045ops"
WSHNetwork.AddPrinterConnection "LPT3", "\\lmexgsrv01\OPS2"
WshNetwork.SetDefaultPrinter "RICOH Aficio 1045 PCL 5e"
End If
If InStr(strGroups, "cn=mrkt-main") Then
WSHNetwork.MapNetworkDrive "i:", "\\lmhmesrv01\ipage"
WSHNetwork.MapNetworkDrive "j:", "\\lmhmesrv01\apps"
WSHNetwork.MapNetworkDrive "g:", "\\lmhmesrv01\csr"
WSHNetwork.MapNetworkDrive "o:", "\\lmhmesrv01\operation"
WSHNetwork.MapNetworkDrive "s:", "\\lmhmesrv01\Marktng"
WSHNetwork.AddPrinterConnection "LPT1", "\\lmexgsrv01\mrktsavin"
WSHNetwork.AddPrinterConnection "LPT2", "\\lmexgsrv01\ops_hp40"
WSHNetwork.AddPrinterConnection "LPT3", "\\lmexgsrv01\1stflrclr"
WshNetwork.SetDefaultPrinter "HP LaserJet 4000 Series PCL 5e"
End If
If InStr(strGroups, "cn=audit-main") Then
WSHNetwork.MapNetworkDrive "j:", "\\lmhmesrv01\apps"
WSHNetwork.MapNetworkDrive "g:", "\\lmhmesrv01\audit"
WSHNetwork.MapNetworkDrive "m:", "\\lmhmesrv01\apps"
WSHNetwork.AddPrinterConnection "LPT1", "\\lmexgsrv01\l1auditlj3"
WSHNetwork.AddPrinterConnection "LPT2", "\\lmexgsrv01\l1adtclr"
WSHNetwork.AddPrinterConnection "LPT3", "\\lmexgsrv01\auditSAVINC32"
WshNetwork.SetDefaultPrinter "auditSAVINC32"
End If

(in reply to briar)
 
 
Post #: 2
 
 Re: logon script - 1/9/2005 5:31:24 AM   
  briar

 

Posts: 2
Score: 0
Joined: 1/9/2005
From:
Status: offline
thanks - good link

will give it a go tomorrow

(in reply to briar)
 
 
Post #: 3
 
 Re: logon script - 1/10/2005 1:45:15 AM   
  netmarcos

 

Posts: 55
Score: 0
Joined: 12/7/2004
From: USA
Status: offline
Group membership is a bit tricky. You are probably getting the error because the CurrentUser.MemberOf property is not always an array. If a user is a mamber of no groups other than Domain Users, the list is Null. If the user is a member of just one additional group, the value is a string. If member of two or more groups, an array. Before you try the Join operation, test to see if the value is an array or not.

I often use this function:


      

(in reply to briar)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> logon script Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts