WshNetwork.UserName not present in Win9x Login Script 
Author Message
 WshNetwork.UserName not present in Win9x Login Script

My WshNetwork.username seems to work fine when logging in through NT, but
when I use a win9x box it comes back null.

If I run the same VBScript when the system is done logging in (At least
authenticating), all the info is there.

Here's the code, pretty much from the samples.
All this code is right at the top of the login script.

I'm running a batch to call the script.

Set WshNetwork = WScript.CreateObject("WScript.Network")
UName = WshNetwork.UserName
'This line comes back empty
CName = WshNetwork.ComputerName                                       This
line comes back with the proper ComputerName



Tue, 18 Feb 2003 00:19:48 GMT  
 WshNetwork.UserName not present in Win9x Login Script
Q233976 - Cannot Retrieve UserName Property in Windows Script Host
http://support.microsoft.com/support/kb/articles/Q233/9/76.ASP

Details not in the KB article above:

1) use On Error Resume Next and On Error GoTo 0 to turn error trapping on/off.
2) execute the logon script under wscript.exe, not cscript.exe.

A related Win9x WshNetwork issue, even after logon:

Q188602 - INFO: UserDomain Method Does Not Work Under Win95 with WSH
http://support.microsoft.com/support/kb/articles/Q188/6/02.ASP

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> My WshNetwork.username seems to work fine when logging in through NT, but
> when I use a win9x box it comes back null.

> If I run the same VBScript when the system is done logging in (At least
> authenticating), all the info is there.

> Here's the code, pretty much from the samples.
> All this code is right at the top of the login script.

> I'm running a batch to call the script.

> Set WshNetwork = WScript.CreateObject("WScript.Network")
> UName = WshNetwork.UserName
> 'This line comes back empty
> CName = WshNetwork.ComputerName                                       This
> line comes back with the proper ComputerName



Tue, 18 Feb 2003 01:30:24 GMT  
 WshNetwork.UserName not present in Win9x Login Script
I have found the follow information

This needs to happen as a work around to
fix a bug with WSH on some Windows95
systems
---------------------------------------------------------------------
User = ""    
Do While User = ""
  User = WSHNetwork.UserName
Loop
--------------------------------------------------------------------

CU



Tue, 18 Feb 2003 02:48:46 GMT  
 WshNetwork.UserName not present in Win9x Login Script
all this does is hang my script..
The "Please wait while your Logon Script" screen stays, and I've even thrown
a timer in to see how many loops it's been going through, and it goes over
60,000


Quote:
> I have found the follow information

> This needs to happen as a work around to
> fix a bug with WSH on some Windows95
> systems
> ---------------------------------------------------------------------
> User = ""
> Do While User = ""
>   User = WSHNetwork.UserName
> Loop
> --------------------------------------------------------------------

> CU



Tue, 18 Feb 2003 03:54:29 GMT  
 WshNetwork.UserName not present in Win9x Login Script

Does it execute under wscript.exe or cscript.exe?  AFAIK, you *need* wscript.exe in this case.

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> all this does is hang my script..
> The "Please wait while your Logon Script" screen stays, and I've even thrown
> a timer in to see how many loops it's been going through, and it goes over
> 60,000



> > I have found the follow information

> > This needs to happen as a work around to
> > fix a bug with WSH on some Windows95
> > systems
> > ---------------------------------------------------------------------
> > User = ""
> > Do While User = ""
> >   User = WSHNetwork.UserName
> > Loop
> > --------------------------------------------------------------------

> > CU



Tue, 18 Feb 2003 04:35:04 GMT  
 WshNetwork.UserName not present in Win9x Login Script
Batch file runs:
wscript vlogin.vbs

I've even tried using
Start /w wscript vlogin.vbs  to make the dos batch program wait.

The "Please wait while your login script executes" screen just stays there.

I've put in a popup in the loop after every 5000 tries, and I've gotten up
to 60,000 before I gave up and clicked cancel.

If I click on the "Cancel" button on the please wait screen, the script
starts to run, but then loses the connection to the drive the script is
running from, and falls apart when it doesn't find certain files I'm
checking.


Quote:
> Does it execute under wscript.exe or cscript.exe?  AFAIK, you *need*

wscript.exe in this case.
Quote:

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --




Quote:
> > all this does is hang my script..
> > The "Please wait while your Logon Script" screen stays, and I've even
thrown
> > a timer in to see how many loops it's been going through, and it goes
over
> > 60,000



> > > I have found the follow information

> > > This needs to happen as a work around to
> > > fix a bug with WSH on some Windows95
> > > systems
> > > ---------------------------------------------------------------------
> > > User = ""
> > > Do While User = ""
> > >   User = WSHNetwork.UserName
> > > Loop
> > > --------------------------------------------------------------------

> > > CU



Tue, 18 Feb 2003 05:06:12 GMT  
 WshNetwork.UserName not present in Win9x Login Script

see my reply to your "WSH for Logon Script" post...

--
Michael Harris
Microsoft.MVP.Scripting
--


Quote:
> Batch file runs:
> wscript vlogin.vbs

> I've even tried using
> Start /w wscript vlogin.vbs  to make the dos batch program wait.

> The "Please wait while your login script executes" screen just stays
there.

> I've put in a popup in the loop after every 5000 tries, and I've gotten up
> to 60,000 before I gave up and clicked cancel.

> If I click on the "Cancel" button on the please wait screen, the script
> starts to run, but then loses the connection to the drive the script is
> running from, and falls apart when it doesn't find certain files I'm
> checking.



> > Does it execute under wscript.exe or cscript.exe?  AFAIK, you *need*
> wscript.exe in this case.

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --



> > > all this does is hang my script..
> > > The "Please wait while your Logon Script" screen stays, and I've even
> thrown
> > > a timer in to see how many loops it's been going through, and it goes
> over
> > > 60,000



> > > > I have found the follow information

> > > > This needs to happen as a work around to
> > > > fix a bug with WSH on some Windows95
> > > > systems

> ---------------------------------------------------------------------
> > > > User = ""
> > > > Do While User = ""
> > > >   User = WSHNetwork.UserName
> > > > Loop
> > > > --------------------------------------------------------------------

> > > > CU



Tue, 18 Feb 2003 07:33:43 GMT  
 WshNetwork.UserName not present in Win9x Login Script

that's not my issue.
The whole loop thing for the username just runs indefinitely. It never
validates the user name no matter how long you wait.

I'm wondering if I have to map another network drive before I get into wsh
to try to make the username appear.
It's not ideal.


Quote:
> see my reply to your "WSH for Logon Script" post...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --



> > Batch file runs:
> > wscript vlogin.vbs

> > I've even tried using
> > Start /w wscript vlogin.vbs  to make the dos batch program wait.

> > The "Please wait while your login script executes" screen just stays
> there.

> > I've put in a popup in the loop after every 5000 tries, and I've gotten
up
> > to 60,000 before I gave up and clicked cancel.

> > If I click on the "Cancel" button on the please wait screen, the script
> > starts to run, but then loses the connection to the drive the script is
> > running from, and falls apart when it doesn't find certain files I'm
> > checking.



> > > Does it execute under wscript.exe or cscript.exe?  AFAIK, you *need*
> > wscript.exe in this case.

> > > --
> > > Michael Harris
> > > Microsoft.MVP.Scripting
> > > --



> > > > all this does is hang my script..
> > > > The "Please wait while your Logon Script" screen stays, and I've
even
> > thrown
> > > > a timer in to see how many loops it's been going through, and it
goes
> > over
> > > > 60,000



> > > > > I have found the follow information

> > > > > This needs to happen as a work around to
> > > > > fix a bug with WSH on some Windows95
> > > > > systems

> > ---------------------------------------------------------------------
> > > > > User = ""
> > > > > Do While User = ""
> > > > >   User = WSHNetwork.UserName
> > > > > Loop

> --------------------------------------------------------------------

> > > > > CU



Tue, 18 Feb 2003 21:53:07 GMT  
 WshNetwork.UserName not present in Win9x Login Script
I've never got this too work under WIN9x. Here's some insight into what I
do:

In the batch file call logon.vbs with CScript.

Example
CScript //NOLOGO \\<Server>\<Share>\<Path>\Logon.vbs

In logon.vbs load the registry RunOnce key with a call to Logon.wsf (or
*.js, *.vbs, whatever) with WScript.

Example
Const HKLM_RUN = _
 "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\Logon Script"
Const RUN_DATA = "MainLogon.wsf"
Const SCRIPT_PATH = "WScript \\<Server>\<Share\<Path>\"
Const KEY_TYPE = "REG_SZ"
strFullPath = SCRIPT_PATH & RUN_DATA
WriteReg(HKLM_RUN, strFullPath, KEY_TYPE)

logon.wsf handles everything properly since it is now running in the WIN9x
GUI environ and you have acccess to anything and everything.

Example of available objects (I use a .wsf, very nice functionality!)
<object id="objFSO" progid="Scripting.FileSystemObject" reference="yes" />
<object id="objNetwork" progid="WScript.Network" reference="yes" />
<object id="objShell" progid="WScript.Shell" reference="yes" />

I'd like to see a show of hands from everyone whos actually got the
'recommended' way to work! I never could, and came up with the above
work-around.

HTH,

Marcus


Quote:
> that's not my issue.
> The whole loop thing for the username just runs indefinitely. It never
> validates the user name no matter how long you wait.

> I'm wondering if I have to map another network drive before I get into wsh
> to try to make the username appear.
> It's not ideal.



> > see my reply to your "WSH for Logon Script" post...

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --



> > > Batch file runs:
> > > wscript vlogin.vbs

> > > I've even tried using
> > > Start /w wscript vlogin.vbs  to make the dos batch program wait.

> > > The "Please wait while your login script executes" screen just stays
> > there.

> > > I've put in a popup in the loop after every 5000 tries, and I've
gotten
> up
> > > to 60,000 before I gave up and clicked cancel.

> > > If I click on the "Cancel" button on the please wait screen, the
script
> > > starts to run, but then loses the connection to the drive the script
is
> > > running from, and falls apart when it doesn't find certain files I'm
> > > checking.



> > > > Does it execute under wscript.exe or cscript.exe?  AFAIK, you *need*
> > > wscript.exe in this case.

> > > > --
> > > > Michael Harris
> > > > Microsoft.MVP.Scripting
> > > > --



> > > > > all this does is hang my script..
> > > > > The "Please wait while your Logon Script" screen stays, and I've
> even
> > > thrown
> > > > > a timer in to see how many loops it's been going through, and it
> goes
> > > over
> > > > > 60,000



> > > > > > I have found the follow information

> > > > > > This needs to happen as a work around to
> > > > > > fix a bug with WSH on some Windows95
> > > > > > systems

> > > ---------------------------------------------------------------------
> > > > > > User = ""
> > > > > > Do While User = ""
> > > > > >   User = WSHNetwork.UserName
> > > > > > Loop

> > --------------------------------------------------------------------

> > > > > > CU



Sun, 23 Feb 2003 02:16:55 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Win9x and WshNetwork.Username

2. WSHNetwork.USerName not working during logon script

3. Having trouble with that WSHNetwork.UserName logon script bug

4. How do I get wshNetwork.UserName within a Windows 95 logon script

5. UserName in Logon Scripts in Win9x

6. Login scripts for WinNT 4.0 and Win9x clients

7. Trouble login script on win9x

8. getting the UserName from a login script

9. Username in login script

10. WSHNetwork.UserName

11. WSHNetwork.UserName samples

12. WSHNetwork.Username

 

 
Powered by phpBB® Forum Software