Solved

user logon name in vbscript

Posted on 2004-03-31
6
2,579 Views
Last Modified: 2008-02-01
Trying to get only the user logon name within a vbscript...  help
0
Comment
Question by:gholton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

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

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"…
An article on effective troubleshooting
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

623 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