Discussion Locked

Login Scripts

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm using the following login script entry to map a network drive using visual basic. Any ideas why this won't work?

dim strUserName
set strUserName = WshNetwork.UserName
wshnetwork.mapnetworkdrive "U:","\\HSNWNT40\" & strUserName

If I use the following without variables it works just fine:

dim wshnetwork
wshnetwork.mapnetworkdrive "R:","\\HSNWNT40\APPS"

3 replies

by clynnlee

What I am trying to do with the strUserName is map the users ID logging map his share drive. Doesn't WshNetwork.UserName give user ID when user logs in?

by inletgrovehs

You can use the following to do that:

'---
Dim objNet : Set objNet = CreateObject("Wscript.Network")
Dim strUser : strUser = objNet.Username

objNet.MapNetworkDrive "R:", "\\HSNWNT40\" & strUser
'---

That is assuming the share name is the username.

However, if the folder name after the username is inside of a share, it would look like this:

'---
Dim objNet : Set objNet = CreateObject("Wscript.Network")
Dim strUser : strUser = objNet.Username

objNet.MapNetworkDrive "R:", "\\HSNWNT40\APPS\" & strUser
'---

This discussion is closed to new replies.