Solved

Login script not working

Posted on 2011-03-10
3
502 Views
Last Modified: 2012-05-11
This login script doesnt work. The bit that isnt working is the conditional mapping of drive G. The admin drive is the only one that seems to work. None of the otehr drive g mappings work.

ON ERROR RESUME NEXT

Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path


Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")

DomainString = Wshnetwork.UserDomain

WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
UserString = WSHNetwork.UserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)

strComputer = WSHNetwork.ComputerName

WSHNetwork.RemoveNetworkDrive "F:", True, True
WSHNetwork.RemoveNetworkDrive "X:", True, True
WSHNetwork.RemoveNetworkDrive "T:", True, True
WSHNetwork.RemoveNetworkDrive "S:", True, True

wscript.sleep 200

WSHNetwork.MapNetworkDrive "F:", "\\Tasman-srv01\Global$",True
WSHNetwork.MapNetworkDrive "X:", "\\Tasman-db1\ASL_Progs\x1\T_100",True
WSHNetwork.MapNetworkDrive "S:", "\\Tasman-srv01\jobscans",True
WSHNetwork.MapNetworkDrive "T:", "\\Tasman-srv01\Global$\Tradelink",True

For Each GroupObj In UserObj.Groups
    Select Case UCase(GroupObj.Name)

        Case "ADMIN"
            WSHNetwork.MapNetworkDrive "G:", "\\srv01\Accounts$",True
        Case "Production"
            WSHNetwork.MapNetworkDrive "G:", "\\srv01\Production$",True
        Case "Comm"
            WSHNetwork.MapNetworkDrive "G:", "\\srv01\Commercial$",True

       
    End Select
Next

set UserObj = Nothing
set GroupObj = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
set WSHSHell = Nothing
Set WSHPrinters = Nothing

wscript.quit
0
Comment
Question by:duncaninnz
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 35104116
Hi, you have
Select Case UCase(GroupObj.Name)

to force GroupObj.Name to uppercase, and then you're checking that against "Production" and "Comm", which should be "PRODUCTION" and "COMM".

Regards,

Rob.
0
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 35104756
0
 

Author Closing Comment

by:duncaninnz
ID: 35111434
YEs that works perfectly. Thanks.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 36
Make a file test.vbs using vbscript 5 69
VBS Script not working correctly. 1 40
How to make an ADE file by code? 11 82
Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now