954,123 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Windows Script Host question (WSH logon script)

Hi ,

Im REAL new with VB and scripting. Im more into networking. I have about 4 departments. I want to MAP the users to their shared drives on the network, and I also want to map their My Documents folder to their shared drive on the network. How do I do that? I found the following snippet on microsoft:

Const ENGINEERING_GROUP = "cn=engineering"
Const FINANCE_GROUP = "cn=finance"
Const HUMAN_RESOURCES_GROUP = "cn=human resources"

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

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

If InStr(strGroups, ENGINEERING_GROUP) Then

wshNetwork.MapNetworkDrive "g:",
"\\FileServer\Engineering\"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\EngLaser"
wshNetwork.AddWindowsPrinterConnection
"\\PrintServer\Plotter"
wshNetWork.SetDefaultPrinter
"\\PrintServer\EngLaser"

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

My info:
Departments:
IT
QA
Finance
Engineering
Executive

Fileserver:
Neptune1
Nas1

I will use Group Policy in AD to implement this. All users have 2000 or XP. So I want to look at the department, and MAP users to their drives. Can someone modify the code for me to reflect that?

Thanks

mujtba
Newbie Poster
3 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

It's much more easier to do these exact things with scriptlogic's tool - desktop authority .
It's a gui based scripting solution and you can pervent yourself from possible mistakes and issues.

Humanvoice
Newbie Poster
2 posts since Jan 2007
Reputation Points: 10
Solved Threads: 0
 

cant you do this through user/group policy?

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,820
Solved Threads: 600
 

it's all easily done with gpmc, scripting, IMO, is for more complex tasks

DimaYasny
Posting Virtuoso
Moderator
1,777 posts since Jan 2007
Reputation Points: 183
Solved Threads: 89
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You