Solved

VBScript Logon Script

Posted on 2009-05-20
9
605 Views
Last Modified: 2012-05-07
Hello,

I am having a little trouble with mapped drives and our logon script.  It appears to me that the portion of our logon script that maps the users' home directories is not working.  If I use AD to do this, I get the home drive, but users who connect remotely, do not.  I'm thinking I need to change my logon script or something.  If I take away the AD connection to the home folder and just use the logon script, no home drive, even though there is a routine in the logon script that is supposed to map the drive.  I've included the code from my logon script up to stuff that really doesn't pertain to this situation.  If we need more, let me know.

Thanks,
Cheese
Option Explicit

Dim objNetwork, objSysInfo, strUserDN

Dim objGroupList, objUser, objFSO

Dim strComputerDN, objComputer

Dim strHomeShare, strHomeDrive

Dim ComputerName
 

Set objNetwork = CreateObject("Wscript.Network")

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objSysInfo = CreateObject("ADSystemInfo")

strUserDN = objSysInfo.userName

strComputerDN = objSysInfo.computerName
 

' Bind to the user and computer objects with the LDAP provider.

Set objUser = GetObject("LDAP://" & strUserDN)

Set objComputer = GetObject("LDAP://" & strComputerDN)
 

' Map user home directory.

strHomeShare = objUser.homeDirectory

If (strHomeShare <> "") Then

    strHomeDrive = objUser.homeDrive

    If (strHomeDrive = "") Then

        strHomeDrive = "H:"

    End If

    On Error Resume Next

    objNetwork.MapNetworkDrive strHomeDrive, strHomeShare

    If (Err.Number <> 0) Then

        On Error GoTo 0

        objNetwork.RemoveNetworkDrive strHomeDrive, True, True

        objNetwork.MapNetworkDrive strHomeDrive, strHomeShare

    End If

    On Error GoTo 0

End If

Open in new window

0
Comment
Question by:cheesebugah
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:Mark Pavlak
ID: 24436718
I am confused.  If you are removing the Home Directory from the AD account then why are you trying to map it based on Information you are pulling from the homDrive atribute it will return an empty value that may be your problem.
0
 

Author Comment

by:cheesebugah
ID: 24436853
jfinner2,

We have an issue here on our network, when people who have been connected to the network, VPN into the network from afar, their H drive is not getting mapped through the VPN.  I was leaning toward using the login script instead of AD to map users' drives, thinking that might be the issue.  I was testing it on my machine.  I removed the H drive from my AD account and logged into the network, but did not get my H drive via the login script either.  So, I think there is something messed up with the login script.  Does that make it any clearer or have I confused you even more?

Thanks,
Cheese
0
 
LVL 6

Accepted Solution

by:
Mark Pavlak earned 500 total points
ID: 24441060
I understand your delmia as I work in an enviroment in which I have a modest handful of users who VPN in from outher offices.  The most inherent issue you will have is that inorder for the H drive to map you must have network.  You dont get network untill VPN is established, as you well know.  Therefore anytype of "Login",Startup" script you may have will not work as they run prior to the establishment of the VPN.  If I may suggest.  By reading the script you already have, it basically queries AD frinds the user account and pulls the .HomeDrive attribute to get the drive letter and the .homeDirectory call will return the path of the homedrive.  THis being said when you blank out those fields in AD so it doesnt mapp the H drive then the script you have will do you no good as those attributes are empty.  What I suggest is.... Let AD handle the H drives, it is the best way in my opinion as it set perms and evrything thing else that is required of a tru Netowrk folder.  Use the script that you have for your VPN users, but not as a "Login" script as you have to establish the VPN before it will run properly.  Put the script in the all users folder\desktop  so that the users of the desktop can double click it mapping their H drive.  The are really two other options you can persue.  Write a script which launches the VPN goes to sleep waits for the network then runs the H drive mapping OR on a per user basis ( i would do this only IF you kepp you H drives statically in one place for the duration of the user account) Manuallly map the H drive and hit the check box for Reconnect at logon.  It will keep the mapping even though it wont be active unless you are on a VPN,  Hope this helps, if you need any scripts written/modified please let me know.
0
 

Author Comment

by:cheesebugah
ID: 24476672
I just wanted to update this question.  We are working on the login script and am leaning toward manually mapping a user's H drive and unchecking the AD Home folder under the user's profile in AD.  It worked for me.

Thanks,
Cheese
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:Mark Pavlak
ID: 24477573
You should uncheck the H drive mapping in their AD profile.  What will happen when they logon on a pc local to your network? No H drive?
0
 

Author Comment

by:cheesebugah
ID: 24477658
Each user has their own computer.  Yes, I have unchecked the radio button in AD for the user's profile to connect to a home folder.  I then manually mapped it.  The user is going to check it in the next couple of days.
0
 
LVL 6

Expert Comment

by:Mark Pavlak
ID: 24477735
Ok I was just looking at what if someone  was logging on local to your domain from another PC.  Although you wont cause a problem if you manually mapp and leave it checked
0
 

Author Comment

by:cheesebugah
ID: 24477762
jfinner2,

Thank you for your help on this matter.  This has been driving us crazy for a long time.  I have always been suspicious of the AD profile setting, but just haven't had a chance to test it.  We're not busy or nothing.  Anyway, I will let you know how it goes in the next day or two.  We are going to be going to a Citrix desktop environment instead of VPN soon, so this won't be an issue through the VPN when we're done with that.

Thanks,
Cheese
0
 

Author Comment

by:cheesebugah
ID: 24597136
The solution that worked best for me in this situation was to uncheck the AD home folder mapping in AD and then manually map the user's home folder making sure "reconnect at logon" is checked, which is the default.  I have had no further isses since.

Thanks,
Cheese
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

18 Experts available now in Live!

Get 1:1 Help Now