Solved

user logon name in vbscript

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

FIPS stands for the Federal Information Processing Standardisation and FIPS 140-2 is a collection of standards that are generically associated with hardware and software cryptography. In most cases, people can refer to this as the method of encrypti…
An article on effective troubleshooting
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 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