Scripts Thread, Problem getting 1 mapped network drive to showup in Coding and Web Development; Hi all
I recently started modifying a VBS logon script for use in my company but im having a weird ...
-
15th November 2012, 07:44 PM #1
- Rep Power
- 0
Problem getting 1 mapped network drive to showup
Hi all
I recently started modifying a VBS logon script for use in my company but im having a weird problem i cant solve regarding the drive mappings. All of the drives i want to map, work correctly except for 1. I cant seem to find any differences between the ones that work and the one that doesnt. It just doesnt show up after a logon. If i map it manually, it works fine. Its probably something stupid, but i am about to start pulling my hair out. Any help is greatly apprecaited. The drive that will not show up is the HR drive (M). Here is the code from the script i am trying to use:
'================================================= =======================================
' Logon Script
'================================================= =======================================
Set objNetwork = CreateObject("WScript.Network")
Set objPrinters = objNetwork.EnumPrinterConnections
Set objShell = CreateObject("Shell.Application")
Set objCMDShell = CreateObject("WScript.Shell")
Set objDrives = objNetwork.EnumNetworkDrives
Set objFSO = CreateObject("Scripting.FileSystemObject")
'-------------------------------------------------------------------
' System Variables
'-------------------------------------------------------------------
strUserName = UCASE(objNetwork.Username)
strComputerName = UCASE(objNetwork.ComputerName)
strLogonServer = UCASE(objCMDShell.ExpandEnvironmentStrings("%LOGON SERVER%"))
strDC = "RRADC1"
'-------------------------------------------------------------------
' Synch time to domain controller
'-------------------------------------------------------------------
objCMDShell.Run "%COMSPEC% /c NET TIME \\" & strDC & " /set /y",0,TRUE
'objCMDShell.Run "\\192.168.0.16\Citrixplugin\CitrixOnlinePluginFul l.exe /silent ENABLE_SSON=" & Q & "Yes" & Q & " SERVER_LOCATION=" & Q & "https://login.ndrhost.com/pnagent/silversearch/config.xml" & Q
'-------------------------------------------------------------------
' This add on will rename the My Computer icon with the Computer Name
'-------------------------------------------------------------------
MCPath = "HKCU\Software\Microsoft\Windows\CurrentVersion\Ex plorer\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
objCMDShell.RegWrite MCPath & "\", strComputerName, "REG_SZ"
'--------------------------------------------
' List Network Drives
'--------------------------------------------
'--Letters-----------------------------------
Rdrive = "R:"
Udrive = "U:"
Hdrive = "H:"
Sdrive = "S:"
Idrive = "I:"
Gdrive = "G:"
Kdrive = "K:"
Mdrive = "M:"
'--Paths-------------------------------------
Rpath = "\\*****\Company"
Upath = "\\*****\users\" & strUserName
Hpath = "\\*****\doccontrol"
Spath = "\\*****\autopol"
Ipath = "\\*****\Engineer"
Gpath = "\\*****\Service"
Kpath = "\\*****\Company\Acct"
Mpath = "\\*****\Company\HR"
'--Names-------------------------------------
Rname = "Company"
Uname = strUserName & "'s Drive"
Hname = "doccontrol"
Sname = "autopol"
Iname = "Engineer"
Gname = "Service"
Kname = "Acct"
Mpath = "HR"
'--------------------------------------------
' Remove all network drives
'--------------------------------------------
On Error Resume Next
For Each strDrive in objDrives
objNetwork.RemoveNetworkDrive strDrive,TRUE,TRUE
Next
'--------------------------------------------
' List Network Printers
'--------------------------------------------
printer01 = "\\**\Service_Refract"
printer02 = "\\**\Sales_Color_LJ2025"
printer03 = "\\**\QCP1320"
printer04 = "\\**\purch_stock"
printer05 = "\\**\LexmarkM412"
printer06 = "\\**\Laserjet5100"
printer07 = "\\**\GrowthPower_Laser"
printer08 = "\\**\DocLaser"
printer09 = "\\**\Autopol_FTC_Laser"
printer10 = "\\**\6250DP"
printer11 = "\\**\stockroom"
'================================================= =======================================
' START ---- Drive and Printer logic
'================================================= =======================================
On Error Resume Next
If IsMember("*** Share") = -1 Then
MapNetworkDrive Rdrive, Rpath, Rname
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Ndrive, Npath, Nname
MapNetworkDrive Sdrive, Spath, Sname
End If
If IsMember("Accounting Share") = -1 Then
MapNetworkDrive Rdrive, Rpath, Rname
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Ndrive, Npath, Nname
MapNetworkDrive Sdrive, Spath, Sname
MapNetworkDrive Kdrive, Kpath, Kname
End If
If IsMember("HR Share") = -1 Then
MapNetworkDrive Rdrive, Rpath, Rname
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Ndrive, Npath, Nname
MapNetworkDrive Sdrive, Spath, Sname
MapNetworkDrive Mdrive, Mpath, Mname
End If
If IsMember("Engineer Share") = -1 Then
MapNetworkDrive Rdrive, Rpath, Rname
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Ndrive, Npath, Nname
MapNetworkDrive Sdrive, Spath, Sname
MapNetworkDrive Tdrive, Tpath, Tname
MapNetworkDrive Wdrive, Wpath, Wname
End If
If IsMember("Service Share") = -1 Then
MapNetworkDrive Rdrive, Rpath, Rname
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Ndrive, Npath, Nname
MapNetworkDrive Sdrive, Spath, Sname
MapNetworkDrive Pdrive, Ppath, Pname
End If
If IsMember("Mobile Share") = -1 Then
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Pdrive, Ppath, Pname
MapNetworkDrive Ndrive, Npath, Nname
MapNetworkDrive Sdrive, Spath, Sname
End If
If IsMember("Density Share") = -1 Then
MapNetworkDrive Rdrive, Rpath, Rname
MapNetworkDrive Udrive, Upath, Uname
MapNetworkDrive Sdrive, Spath, Sname
End If
objNetwork.AddWindowsPrinterConnection printer01
objNetwork.AddWindowsPrinterConnection printer02
objNetwork.AddWindowsPrinterConnection printer03
objNetwork.AddWindowsPrinterConnection printer04
objNetwork.AddWindowsPrinterConnection printer05
objNetwork.AddWindowsPrinterConnection printer06
objNetwork.AddWindowsPrinterConnection printer07
objNetwork.AddWindowsPrinterConnection printer08
objNetwork.AddWindowsPrinterConnection printer09
objNetwork.AddWindowsPrinterConnection printer10
objNetwork.AddWindowsPrinterConnection printer11
'objNetwork.SetDefaultPrinter printer01
'================================================= =======================================
' END ---- Drive and Printer logic
'================================================= =======================================
'------------------------------------------------------------
' Drive Mapping Function
'------------------------------------------------------------
Private Function MapNetworkDrive(driveLetter,drivePath,driveName)
objNetwork.MapNetworkDrive driveLetter, drivePath
objShell.NameSpace(driveLetter & "\").Self.Name = driveName
End Function
'------------------------------------------------------------
' Check Group Membership Function
'------------------------------------------------------------
Private Function IsMember(groupName)
Set netObj = CreateObject("WScript.Network")
domain = netObj.UserDomain
user = netObj.UserName
flgIsMember = false
Set userObj = GetObject("WinNT://" & domain & "/" & user & ",user")
For Each grp In userObj.Groups
If grp.Name = groupName Then
flgIsMember = true
Exit For
End If
Next
IsMember = flgIsMember
Set userObj = nothing
Set netObj = nothing
End Function
Last edited by Toasterleavins; 15th November 2012 at 07:56 PM.
-
-
IDG Tech News
-
19th November 2012, 11:48 AM #2
- Rep Power
- 0
Hi,
Is "HR Share" a member of the right group?
You could put a messagebox in the code to show the variable "Ismember" when it tries to map the "HR Share".
If it is a member of the group, "Ismember" should be true, else its false and therefore won't map the drive
-
SHARE: 
Similar Threads
-
By chekmate1984 in forum Windows Server 2008 R2
Replies: 8
Last Post: 11th October 2012, 04:35 PM
-
By googlemad in forum Windows
Replies: 4
Last Post: 22nd October 2009, 02:07 PM
-
By sidewinder in forum Windows
Replies: 5
Last Post: 26th November 2007, 06:40 PM
-
By spikezster in forum Windows
Replies: 3
Last Post: 17th October 2007, 09:15 AM
-
By Crackcode in forum How do you do....it?
Replies: 0
Last Post: 21st April 2007, 10:03 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules