Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to identify each user's desktop user id?

Status
Not open for further replies.

barny2006

MIS
Joined
Mar 30, 2006
Messages
521
Location
US
hi,
i have a script that reads a table in a database on a network drive (drive s:) and creates an excel spread sheet on the user's local computer desk top.
my question is: is there anyway to find the user id from the local pc and plug it into the script, so that the excel file can be created on each user's desktop without them having to prompt them to enter their user id.
the path to each user id is like this:
c:\documents and settings\userid\desktop\excel_file.xls
 
If you open a command prompt and type "set" (without the quotes) it will show you all the current variables that are set. There should be one USERNAME=(current user). When running the script, substitute %USERNAME% and it will put in the current user.
 
thanks,
i'm not sure how i would put %username% where in the script.
let's say the code is:
user = %username%
is this what you mean?
 
COPY /Y S:\excel_file.xls "%USERPROFILE%\Desktop\excel_file.xls"

Using %USERPROFILE% will take account of any redirected user profile folders rather than assuming that it is in the C:\Documents and Settings location.

John
 
i'm not sure if this
"COPY /Y S:\excel_file.xls "%USERPROFILE%\Desktop\excel_file.xls"

is a script command.
this looks like a dos command, which i'm trying to avoid inside the script.
 
===========
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Computer Name = " & WshNetwork.ComputerName & vbCrLF _
& "User Name = " & WshNetwork.UserName & vbCrLf _
& "Domain = " & WshNetwork.UserDomain

============ end of sample script

You can assign WshNetwork.UserName to a variable that will be used in your pathing statement.


____________________________
Users Helping Users
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top