Jump to content

Toasterleavins

Members
  • Posts

    1
  • Joined

  • Last visited

Reputation

0 Neutral

About Toasterleavins

  1. 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("%LOGONSERVER%")) 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\CitrixOnlinePluginFull.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\Explorer\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
×
×
  • Create New...