Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 9th, 2004, 06:48 AM
Authorized User
Join Date: Jun 2003
Location: Aalst, Vlaanderen, Belgium.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default objNetwork.UserName


I'vze got an issue with the following piece of code :

<script language="vbscript">
Dim strUsername, objNetwork
Set objNetwork = CreateObject("WScript.Network")
If trim(objNetwork.UserName) <> "" Then strUsername = objNetwork.Username

When I execute the code on a local PC [plain HTML], the variable gets populated with the current username logged on in Windows. When the code is located on the server, the variable gets the value of "Undefined". This worked before and seems to have changed since the servers got upgraded to Service Pack 4. Any ideas ? Or any alternative ways to get the Windows Username ? Thanks.

Reply With Quote
  #2 (permalink)  
Old August 9th, 2004, 11:10 PM
Friend of Wrox
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post

Hi Sebastiaan,

I am not sure about the reason for that. But, see if this helps.

<script language="vbscript">
Dim strUsername, wshShell 
Set wshShell = CreateObject("WScript.Shell")
strUser = wshShell.ExpandEnvironmentStrings("%USERNAME%")
'This uses the Environment variable %USERNAME%
'Try Echo %USERNAME% in command prompt.
<script language="vbscript">
Dim strUsername, adsNTSysInfo
Set adsNTSysInfo = CreateObject("WinNTSystemInfo")
strUsername = adsNTSysInfo.UserName
- Vijay G
Strive for Perfection
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect Username dparsons ASP.NET 1.0 and 1.1 Professional 2 April 12th, 2006 02:20 PM
Username Changes Ben Horne Forum and Wrox.com Feedback 2 March 12th, 2004 12:20 PM

All times are GMT -4. The time now is 08:34 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.