Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Home drive is not mapping in Login Script

Posted on 2009-06-29
3
Medium Priority
?
507 Views
Last Modified: 2012-05-07
I am working on a logon script for a small domain. I have added the code below. Initially I needed to add the ie pop up for our online Time and Labor application. I decided to rework the entire script while I was at it to streamline things. All aspects seem to be functioning with the exception of the J: drive mapping on line 23 below. Any help would be appreciated. I am also in need of a logout script that will again cause an ie window to pop up for the time and labor application before shutting down.
ON ERROR RESUME NEXT
 
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path
 
Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'Automatically get user's domain name
DomainString = Wshnetwork.UserDomain 
'Get Windows Directory
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
 
'Get user name
UserString = WSHNetwork.UserName
'Bind to user object to get user name and check for group memberships later
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
 
'Get the computer name
strComputer = WSHNetwork.ComputerName
 
'Disconnect ALL mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
    WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next 
 
'PC disconnect, wait 300 milliseconds
wscript.sleep 300
 
'Map drives for all users
 WSHNetwork.MapNetworkDrive "J:", "\\rfmain\user\" & UserString,True
 WSHNetwork.MapNetworkDrive "K:", "\\rfaccount\olms",True
 WSHNetwork.MapNetworkDrive "Q:", "\\rfvit\app-inst",True
 WSHNetwork.MapNetworkDrive "S:", "\\rfmain\share",True
 
'Check group membership and map drives accordingly
For Each GroupObj In UserObj.Groups
'Force upper case comparison of the group names, otherwise this is case sensitive.
    Select Case UCase(GroupObj.Name)
    'Check for group memberships and take needed action
        Case "DOMAIN ADMINS"
	    wshnetwork.MapNetworkDrive "R:", "\\RFMAIN\D$",True
 
        Case "CPI_USERS"
	    wshnetwork.MapNetworkDrive "T:", "\\RFMAIN\SHARE",True
 
        Case "UTIL"
	    wshnetwork.MapNetworkDrive "Y:", "\\RFMAIN\UTIL",True
 
        Case "SUMMATION"
	    wshnetwork.MapNetworkDrive "N:", "\\RFMAIN\SUMMATION",True
 
        Case "NON-EXEMPT"
	    Set oIE = WScript.CreateObject("InternetExplorer.Application") 
	    oIE.Visible = True 
	    oIE.Navigate("https://timeandlabor.paychex.com/secure/login.asp")
 
    End Select
Next
 
'Remove ALL old printers
Set WSHPrinters = WSHNetwork.EnumPrinterConnections
For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
 
'Remove specific printers
wshnetwork.RemovePrinterConnection "\\RFMAIN\acctg2",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\BarcodePrint",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Canon.acct",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Canon.8th.BW.copyroom",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Canon.8th.copyroom",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Canon.9th.BW",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Canon.9th.copyroom",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Canon.8th.BW",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Color-8th",True,True
wshnetwork.RemovePrinterConnection "\\RFMAIN\Color-9th",True,True
                                
'Install Printers
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Canon.8th.BW.copyroom"
'wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Canon.8th.copyroom"
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Canon.9th.BW"
'wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Canon.9th.copyroom"
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Canon.8th.BW"
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Color-9th"
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\Color-8th"
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\XEROX 8TH COLOR COPYROOM"
wshnetwork.AddWindowsPrinterConnection "\\RFVPRINT\XEROX 9TH COLOR COPYROOM"
 
set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing
 
wscript.quit

Open in new window

0
Comment
Question by:RFEMHelpdesk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Expert Comment

by:jwarnken
ID: 24737371
There are a lot of issues that can happen 1st step would be to comment out ON ERROR RESUME NEXT and see if there is an error occurring.
0
 
LVL 3

Expert Comment

by:astroviper
ID: 24737672
If there are parts that are not necessarily going to complete without error every time and you need the script to continue so that you can test the rest of the code, you can enclose sections with:

On Error Resume Next
...
On Error Goto 0
0
 

Accepted Solution

by:
RFEMHelpdesk earned 0 total points
ID: 25068172
Determined that the mapping issue was directly related to the manner in which the AD user account was configured. Once the AD account was corrected the mapping occurred as anticipated.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question