Hi All,
I was wondering if someone could please help me out with a login vbsript.
Am still a novice at VB, but am trying my best to do the following:
Judging by computername prefix (which is different from office to office)i would like specific prefixes to map their own drive mappings.
eg. london pc`s starting off with lon-
So if a pc starts off with lon- , it must go to the london area of the login script and map those drive letters.
Here is a sample of what i am trying to do, but am really struggling to write it.
It might not even make sense, sorry for it being such a mess.
Dim wshNetwork, sWorkstationPrefixlon, sWorkstationPrefixrea, sWorkstationPrefixdub, sWorkstationPrefixgil
set wshshell=createobject("wscript.shell")
Set ObjEnv=wshshell.Environment("PROCESS")
strComputerName = ObjEnv("COMPUTERNAME")
str2Search4 = "ctx"
sWorkstationPrefixbir = "lon"
sWorkstationPrefixrea = "rea"
sWorkstationPrefixdub = "dub"
sWorkstationPrefixgil = "gil"
Dim UserGroups(2000)
Dim GroupCount
Dim objGroup
Dim adsSystemInfo
sCommand = "%COMSPEC% /C "
Set wshNetwork = CreateObject(WScript.Network)
''' Ensure All Constants are in lowercase
Const LONDON = "lon"
Const READING = "rea"
Const GUILDFORD = "gil"
Const DUBLIN = "dub"
If InStr(1, strGroupsbir, BIRMINGHAM) Then
wshNetwork.MapNetworkDrive "L:", "\\dc-lon\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
ElseIf InStr(1, strGroupsrea, READING) Then
wshNetNetwork.MapNetworkDrive "L:", "\\dc-rea\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
ElseIf InStr(1, strGroupsgil, GUILDFORD) Then
wshNetNetwork.MapNetworkDrive "L:", "\\dc-gil\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
ElseIf InStr(1, strGroupsdub, DUBLIN) Then
wshNetNetwork.MapNetworkDrive "L:", "\\dc-dub\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
End If
Set wshNetwork = Nothing
I was wondering if someone could please help me out with a login vbsript.
Am still a novice at VB, but am trying my best to do the following:
Judging by computername prefix (which is different from office to office)i would like specific prefixes to map their own drive mappings.
eg. london pc`s starting off with lon-
So if a pc starts off with lon- , it must go to the london area of the login script and map those drive letters.
Here is a sample of what i am trying to do, but am really struggling to write it.
It might not even make sense, sorry for it being such a mess.
Dim wshNetwork, sWorkstationPrefixlon, sWorkstationPrefixrea, sWorkstationPrefixdub, sWorkstationPrefixgil
set wshshell=createobject("wscript.shell")
Set ObjEnv=wshshell.Environment("PROCESS")
strComputerName = ObjEnv("COMPUTERNAME")
str2Search4 = "ctx"
sWorkstationPrefixbir = "lon"
sWorkstationPrefixrea = "rea"
sWorkstationPrefixdub = "dub"
sWorkstationPrefixgil = "gil"
Dim UserGroups(2000)
Dim GroupCount
Dim objGroup
Dim adsSystemInfo
sCommand = "%COMSPEC% /C "
Set wshNetwork = CreateObject(WScript.Network)
''' Ensure All Constants are in lowercase
Const LONDON = "lon"
Const READING = "rea"
Const GUILDFORD = "gil"
Const DUBLIN = "dub"
If InStr(1, strGroupsbir, BIRMINGHAM) Then
wshNetwork.MapNetworkDrive "L:", "\\dc-lon\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
ElseIf InStr(1, strGroupsrea, READING) Then
wshNetNetwork.MapNetworkDrive "L:", "\\dc-rea\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
ElseIf InStr(1, strGroupsgil, GUILDFORD) Then
wshNetNetwork.MapNetworkDrive "L:", "\\dc-gil\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
ElseIf InStr(1, strGroupsdub, DUBLIN) Then
wshNetNetwork.MapNetworkDrive "L:", "\\dc-dub\Local_Sysdocs"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8000N"
' wshNetNetwork.AddWindowsPrinterConnection "\\Eklinserver01\HP8100N"
' wshNetNetwork.SetDefaultPrinter "\\Eklinserver01\HP8100N"
End If
Set wshNetwork = Nothing