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

VBScript not working on Server 2008 32 bit

Status
Not open for further replies.

pjgigaroa

Technical User
Jul 19, 2010
1
US
I have a script to get a client's computer name when they log into the server. It worked in 2003 server, but now that I use it on 2008 server 32 bit, I don't get the clients name back.

OPTION EXPLICIT 'Force all variable to be declared

' Declare my variables
Dim fso, ws, file_to_open, DisplayClientExe_PATH, file_to_open_PATH
Dim WSHNetwork, strWorkstation, Wshshell, objEnv


Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("Volatile")
strWorkstation = objEnv("CLIENTNAME")
wscript.echo (strWorkstation)
wscript.echo "This does work
 
Try this.
[tt]
strWorkstation = objEnv("CLIENTNAME")
do while len(strWorkstateion)=0
wscript.sleep 50
strWorkstation=objEnv("CLIENTNAME")
loop
[/tt]
If objEnv("CLIENTNAME") "ever" be empty, it would loop infinite. Hence, at the test stage, try add a damage control.
[tt]
dim n, nmax
nmax=100 'wait at most 100 unit of sleep (50, say, hence 5 sec)
n=0
strWorkstation = objEnv("CLIENTNAME")
do while len(strWorkstateion)=0 and n<nmax
wscript.sleep 50
n=n+1
strWorkstation=objEnv("CLIENTNAME")
loop
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top