Solved

user logon name in vbscript

Posted on 2004-03-31
6
2,554 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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. …
Have you ever set up your wireless router at home or in the office to find that you little pop-up bubble in the bottom right-hand corner of Windows read "IP Conflict - One of more computers on the network have been assigned the following IP address"…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

21 Experts available now in Live!

Get 1:1 Help Now