Solved

user logon name in vbscript

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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"…
The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

680 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