Hi

Is it possibel to check if Terminal Server is up and running from an
remote computer?

/Romme

RE: How to monitor if Terminal Server is running from remote computer? by Robert

Robert
Tue May 23 02:48:02 CDT 2006

Hi Romme,

I'll hope you are still intrested in such a script?
Here is a sample script that I am using, check it out if it's usefull for you.
The only thing you must change in the script is to enter the IP address or
DNS name of your computer. Or you can create an inputbox for that.

'=#=#=#= Sample script =#=#=#=

On error resume Next
err.clear()

Dim objWMIService, objItem, colItems, msg
Dim strComputer, strLastBootTime, strDateTime, strLastUpTime

' =#=#=#=#==#=#=#=#= Begin Main Program =#=#=#=#==#=#=#=#=

'=#=#= Read Boot Time =#=#=

strComputer = "xxx.xxx.xxx.xxx" 'Enter here an IP-address or DNS name of
your server

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

If err.number = 0 Then
Set colItems = objWMIService.ExecQuery("Select * from
Win32_OperatingSystem",,48)
For Each objItem in colItems
strLastUpTime = objItem.LastBootUpTime
Next
strDateTime = Now
strLastBootTime = GetBootTime(strLastUpTime)
msg = "Scan date: " & strDateTime & vbCrLf & vbCrLf
msg = msg & "Computer: " & strComputer & vbCrLf
msg = msg & "Last Boot Time: " & strLastBootTime
Else
' Write the "Error" status
msg = "Scan date: " & strDateTime & vbCrLf & vbCrLf
msg = "Computer " & strComputer & " Failed: " & vbCrLf
msg = msg & Err.Description
End If

MsgBox Msg

WScript.Quit

'=#=#=#=#==#=#=#=#= End Main Program =#=#=#=#==#=#=#=#=

'=#=#= Get boot up time of the server =#=#=
Function GetBootTime(dtmBootup)
On error resume Next
Dim dtmTimeUp, dtmLastBootupTime, dtmSystemUpTime, strBootTime
dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
dtmSystemUpTime = DateDiff("h", dtmLastBootUpTime, Now)
If dtmSystemUptime > 24 Then
dtmTimeUp = DateDiff("d",dtmLastBootUpTime, Now) & " day(s)"
Else
dtmTimeUp = dtmSystemUptime & " hour(s)"
End If
strBootTime = dtmLastBootupTime & " (" & dtmTimeUp & " ago)"
GetBootTime = strBootTime
End Function

'=#=#=#=#==#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#

'=#=#= Convert to Date dd/mm/yyyy =#=#=
Function WMIDateStringToDate(dtmDate)
On error resume Next
WMIDateStringToDate = CDate(Mid(dtmDate, 7, 2) & "/" & _
Mid(dtmDate, 5, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) _
& ":" & Mid(dtmDate,13, 2))
End Function

'=#=#=#=#==#=#=#=#==#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=

'=#=#= Convert to Date mm/dd/yyyy =#=#=
'Function WMIDateStringToDate(dtmDate)
' On error resume Next
' WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
' Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
' & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) _
' & ":" & Mid(dtmDate,13, 2))
'End Function

'=#=#=#=#==#=#=#=#==#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=


"romme@sitevision.dk" wrote:

> Hi
>
> Is it possibel to check if Terminal Server is up and running from an
> remote computer?
>
> /Romme
>
>

Re: How to monitor if Terminal Server is running from remote computer? by Dr

Dr
Wed May 24 09:11:06 CDT 2006

JRS: In article <186DAFD2-57CB-4294-A249-5CD8EFF5DD7F@microsoft.com>,
dated Tue, 23 May 2006 00:48:02 remote, seen in news:microsoft.public.sc
ripting.vbscript, Robert <Robert@discussions.microsoft.com> posted :
>
>'=#=#= Convert to Date dd/mm/yyyy =#=#=
>Function WMIDateStringToDate(dtmDate)
> On error resume Next
> WMIDateStringToDate = CDate(Mid(dtmDate, 7, 2) & "/" & _
> Mid(dtmDate, 5, 2) & "/" & Left(dtmDate, 4) _
> & " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) _
> & ":" & Mid(dtmDate,13, 2))
>End Function

It seems that dtmDate is of the form "YYYYMMDDhmmss". In Javascript,

dtmDate = "YYYYMMDDhhmmss"
dtmDate.replace(/(....)(..)(..)(..)(..)(..)/, "$3/$2/$1 $4:$5:$6")

gives string "DD/MM/YYYY hh:mm:ss".

Can one not do similarly in later VBS? it would seem possibly briefer
and more efficient.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.