Solved

user logon name in vbscript

Posted on 2004-03-31
6
2,560 Views
Last Modified: 2008-02-01
Trying to get only the user logon name within a vbscript...  help
0
Comment
Question by:gholton
  • 3
  • 2
6 Comments
 

Author Comment

by:gholton
ID: 10728421
More specifically... I am trying to get the map a directory that uses just the first name or logon name.   \\computer\share\logon name\data.   \\testserver\excel\mark  where "Mark" is the name the user uses to login.  His full name is "Mark Smith"

we are using a logon script to do this and using the code below only gives us the full name

Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)

If InStr(strGroups, LABELS_GROUP) Then
    wshNetwork.MapNetworkDrive "l:", "\\testsever\excel\" & Currentuser.name
End If

Please help
0
 
LVL 16

Accepted Solution

by:
mdiglio earned 125 total points
ID: 10731787
Hello,
Try this code and let us know how it works for you
Good Luck


'!!!!Begin Copy
Dim WshNetwork, Uname

'//On error resume next

'//create WshNetwork object
Set WshNetwork = WScript.CreateObject("WScript.Network")
Uname = WshNetwork.UserName
'//wscript.echo uname

If InStr(strGroups, LABELS_GROUP) Then
  WshNetwork.MapNetworkDrive "l:", "\\testsever\excel\" & Uname & ""
End If
'!!!!End Copy
0
 

Author Comment

by:gholton
ID: 10747921
Thanks.

We give that a shot and see if we get better results...

Glenn
0
 

Author Comment

by:gholton
ID: 10864150
Thanks for you help mdiglio,  We are have solved are problem and moved on.  We ended up simply creating directories with the users full name and mapping our drive to that directory using the USERNAME variable.... forgetting about having it just be the users first name.

It works and all users report no problems.

We are closing out this question.
Best regards..

Glenn Holton
0
 
LVL 16

Expert Comment

by:mdiglio
ID: 10864281
Glad you got it working!
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

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

Suggested Solutions

Sometimes you might need to configure routing based not only on destination IP address, but also on a combination of destination IP address (or hostname) and destination port number. I will describe a method how to accomplish this with free tools. …
This article is in response to a question (http://www.experts-exchange.com/Networking/Network_Management/Network_Analysis/Q_28230497.html) here at Experts Exchange. The Original Poster (OP) requires a utility that will accept a list of IP addresses …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

15 Experts available now in Live!

Get 1:1 Help Now