Hallo,

i have the following problem, i have a Windows TS 2003 with 3 Clients. On
startup the 3 clients autoconnect to the TS2003. But the problem is, when
all 4 machines start at the same time, the 3 Clients start faster than the
TS, the get an errormessage, when the try to connect to the TS.
So i tried to write a script, which waits if the TermService is startet
(Status=4), and afterwars connects to the Server.
But the problem is, if the TS is down, the Script can't create the Object
"objComputer" and it jumps in the IF (see below).
Is there a way to ask if the Object "objComputer" is created correctly?


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
strComputername="server1"
strServiceName="TermService"
strProgram="mstsc.exe"
'
********************************************************************************************

Do
Set objComputer = GetObject("WinNT://" & strComputername)
Set objService = objComputer.GetObject("Service",strServiceName)
If objService.status = 4 Then
Set objProgram = CreateObject("WScript.Shell")
objProgram.Run strProgram
Exit Do
End If
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


thanks for help

mfg martin

RE: Waiting if TermService is started by Kendoh

Kendoh
Mon Sep 12 21:14:03 CDT 2005

You can create the object before the do. Shouldn't you do a "Do until"
service status = 4? Then can execute the program???

"Martin Schasching" wrote:

> Hallo,
>
> i have the following problem, i have a Windows TS 2003 with 3 Clients. On
> startup the 3 clients autoconnect to the TS2003. But the problem is, when
> all 4 machines start at the same time, the 3 Clients start faster than the
> TS, the get an errormessage, when the try to connect to the TS.
> So i tried to write a script, which waits if the TermService is startet
> (Status=4), and afterwars connects to the Server.
> But the problem is, if the TS is down, the Script can't create the Object
> "objComputer" and it jumps in the IF (see below).
> Is there a way to ask if the Object "objComputer" is created correctly?
>
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> strComputername="server1"
> strServiceName="TermService"
> strProgram="mstsc.exe"
> '
> ********************************************************************************************
>
> Do
> Set objComputer = GetObject("WinNT://" & strComputername)
> Set objService = objComputer.GetObject("Service",strServiceName)
> If objService.status = 4 Then
> Set objProgram = CreateObject("WScript.Shell")
> objProgram.Run strProgram
> Exit Do
> End If
> Loop
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
>
> thanks for help
>
> mfg martin
>
>
>

Re: Waiting if TermService is started by Martin

Martin
Tue Sep 13 10:19:26 CDT 2005

hi,

the Do until is the better way, you are right and i will change my script.
But the problem was, if the Object "objService" couldn be created -->
because the "objComputer" couldn't be craeted, the script alway executet the
if-block (also when objService.status was <> 4).

now i have solved the problem:


Do
Set objComputer = GetObject("WinNT://" & strComputername)
Set objService = objComputer.GetObject("Service",strServiceName)
NoError=(Err.Number=0)
If NoError Then
If objService.status = 4 Then
Set objProgram = CreateObject("WScript.Shell")
objProgram.Run strProgram
Exit Do
End If
End If
Loop


thanks
martin

"Kendoh" <Kendoh@discussions.microsoft.com> schrieb im Newsbeitrag
news:D2E36661-6291-45F7-9D02-EBE01BF7D8C6@microsoft.com...
> You can create the object before the do. Shouldn't you do a "Do until"
> service status = 4? Then can execute the program???
>
> "Martin Schasching" wrote:
>
>> Hallo,
>>
>> i have the following problem, i have a Windows TS 2003 with 3 Clients. On
>> startup the 3 clients autoconnect to the TS2003. But the problem is, when
>> all 4 machines start at the same time, the 3 Clients start faster than
>> the
>> TS, the get an errormessage, when the try to connect to the TS.
>> So i tried to write a script, which waits if the TermService is startet
>> (Status=4), and afterwars connects to the Server.
>> But the problem is, if the TS is down, the Script can't create the Object
>> "objComputer" and it jumps in the IF (see below).
>> Is there a way to ask if the Object "objComputer" is created correctly?
>>
>>
>> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>> strComputername="server1"
>> strServiceName="TermService"
>> strProgram="mstsc.exe"
>> '
>> ********************************************************************************************
>>
>> Do
>> Set objComputer = GetObject("WinNT://" & strComputername)
>> Set objService = objComputer.GetObject("Service",strServiceName)
>> If objService.status = 4 Then
>> Set objProgram = CreateObject("WScript.Shell")
>> objProgram.Run strProgram
>> Exit Do
>> End If
>> Loop
>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>
>>
>> thanks for help
>>
>> mfg martin
>>
>>
>>