At what point does the user envioment get loaded by Win2000 VBS script?

  • Thread starter Thread starter Arch Willingham
  • Start date Start date
A

Arch Willingham

I have a VBS file that I use as part of the log in. One line says
"Sh.LogEvent 4, "Terminal Server Logon by " & EnvUserName & " from " & sys".
When I manually run the file while sitting here, it writes the following to
the even log:

"Terminal Server Logon by dog from TRUCK"

however when it loads automatically during the login, it writes the
following:

"Terminal Server Logon by from TRUCK" (I.E. the variable USERNAME) is not
shown.

Any idea why?

Thanks,

Arch Willingham
 
Arch said:
I have a VBS file that I use as part of the log in. One line says
"Sh.LogEvent 4, "Terminal Server Logon by " & EnvUserName & " from " & sys".
When I manually run the file while sitting here, it writes the following to
the even log:

"Terminal Server Logon by dog from TRUCK"

however when it loads automatically during the login, it writes the
following:

"Terminal Server Logon by from TRUCK" (I.E. the variable USERNAME) is not
shown.

Any idea why?

Hi,

What's the client OS, and how do you retrieve the value for EnvUserName?

On Win9x the current user name cannot be retrieved until the profile has
been established on the local client, which happens after the logon script
starts. Logon scripts on Win9x clients require a loop to retrieve UserName
from WshNetwork, to force completion of authentication on the client.
Otherwise, UserName is blank. I have never seen this be an issue on NT, W2k,
or XP clients. I'm not sure about Terminal Services.
 
The server is an NT2000 machine...all of the clients are terminal server
clients. Here are the lines that make it happen:

Set WshProcessEnvironment = Sh.Environment("Process")
EnvUserName = WshProcessEnvironment("username")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
Sh.LogEvent 4, "Terminal Server Logon by " & EnvUserName & " from " & sys
 
It seems like your code should work, but I would suggest posting this
question in a Terminal Services newsgroup. I can't track down how the
environment variables are set during logon with Terminal Services. Some of
the people that monitor the TS newsgroups like to answer scripting
questions.

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--

Arch Willingham said:
The server is an NT2000 machine...all of the clients are terminal server
clients. Here are the lines that make it happen:

Set WshProcessEnvironment = Sh.Environment("Process")
EnvUserName = WshProcessEnvironment("username")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
Sh.LogEvent 4, "Terminal Server Logon by " & EnvUserName & " from " & sys
 
Thanks!
Richard Mueller said:
It seems like your code should work, but I would suggest posting this
question in a Terminal Services newsgroup. I can't track down how the
environment variables are set during logon with Terminal Services. Some of
the people that monitor the TS newsgroups like to answer scripting
questions.

--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--

Arch Willingham said:
The server is an NT2000 machine...all of the clients are terminal server
clients. Here are the lines that make it happen:

Set WshProcessEnvironment = Sh.Environment("Process")
EnvUserName = WshProcessEnvironment("username")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
Sh.LogEvent 4, "Terminal Server Logon by " & EnvUserName & " from " & sys



Richard Mueller said:
Arch Willingham wrote:

I have a VBS file that I use as part of the log in. One line says
"Sh.LogEvent 4, "Terminal Server Logon by " & EnvUserName & " from " &
sys".
When I manually run the file while sitting here, it writes the following
to
the even log:

"Terminal Server Logon by dog from TRUCK"

however when it loads automatically during the login, it writes the
following:

"Terminal Server Logon by from TRUCK" (I.E. the variable USERNAME)
is
not
shown.

Any idea why?

Hi,

What's the client OS, and how do you retrieve the value for EnvUserName?

On Win9x the current user name cannot be retrieved until the profile has
been established on the local client, which happens after the logon script
starts. Logon scripts on Win9x clients require a loop to retrieve UserName
from WshNetwork, to force completion of authentication on the client.
Otherwise, UserName is blank. I have never seen this be an issue on
NT,
W2k,
 
Back
Top