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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get 9X UserName/ComputerName into my NT Login Script?

Desktop Administration

How do I get 9X UserName/ComputerName into my NT Login Script?

by  jnicks  Posted    (Edited  )
Win 9x doesn't support NT Login Script UserName and ComputerName.

You could get those as well as workgroup and domain from Win 3.11 Lan Manager, but this is not a history course. The support for them was removed for marketing purposes.

The following ten (0x10) line VB5 program will make a batch file that can be run to correctly set UserName and ComputerName. Below.

It is used like:
Login Script
Code:
    . . .
    compuser
    call setUser.bat
    . . .
and [tt]compuser.bat[/tt] will set the environment variables correctly.

To use it you need the Win32 VB5 environment, pick up MSVBM500.exe and run it, from Microsoft, the file is at http://download.microsoft.com/download/vb50pro/utility/1/win98/EN-US/Msvbvm50.exe

and the explanation page is at
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q180071


If you do not have a compiler there is source and an EXE downloadable from http://www.roninsoftwaregroup.com/compuser.htm
You'll still need the humongous MSVBM environment.

----------------------------- Login9X.bas ------------
Code:
Attribute VB_Name = "login9x"
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Sub Main()
  comp$ = String$(300, 0):  User$ = comp$
  k& = GetComputerName(comp$, 300):   trimit comp$
  k& = GetUserName(User$, 300):  trimit User$
  Open "SetUser.bat" For Output As #1
    Print #1, "set username=" + User$
    Print #1, "set computername=" + comp$
  Close
End Sub
Sub trimit(a$)
  j = InStr(a$, Chr$(0))
  If j Then a$ = Left$(a$, j - 1)
End Sub
[code]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top