I have attached some .asp code that can be used with a web page. It also uses RemoteControl.exe to query the remote AMT client. It will print out the power state including sleep and hibernate. Just create a form on a webpage that calls this .asp and passes along the 'hostname' tag with the fqdn or ip address of the client.
<%@ Language=VBScript %>
<%
dim strFQDN
strFQDN = Request.Form("HostName")
%>
<HTML>
<HEAD>
<TITLE>vPro Demo Administration</TITLE>
</HEAD>
<BODY BGCOLOR = FFFFFF>
<%
' Program constants and variables
const strUser = "admin"
const strPass = "P@ssw0rd"
const ForReading = 1, ForWriting = 2, ForAppending = 8
const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
dim objShell : Set objShell = nothing
dim objFSO : Set objFSO = nothing
dim objOutFile : Set objOutFile = nothing
dim objTextStream : Set objTextStream = nothing
dim strCMD
dim strLine, strTMP
dim strMessage
dim strPhysPath
' Initialize the shell to run a command and to access the file system
Set objShell = CreateObject("WScript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Make sure there is a HostName
if strFQDN = "" then
ErrorExit("No Host Name supplied")
end if
' Set variable with path to iso_launcher
strPhysPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "iso_launcher\"
objShell.CurrentDirectory = strPhysPath
' Setup command line string to execute, starts remotecontrol.exe query to see if client is powered off
strCMD = "%COMSPEC% /c remotecontrol.exe -p -user " & strUser & " -pass " & strPass & " http://" & strFQDN & ":16992/RemoteControlService >out.txt"
objShell.Run strCmd, 0, True
' Read in a stream of text from remotecontrol.exe
Set objOutFile = objFSO.GetFile("out.txt")
Set objTextStream = objOutfile.OpenAsTextStream(ForReading, TristateUseDefault)
do until objTextStream.AtEndOfStream
strLine = objTextStream.ReadLine
if (InStr(strLine, "SOAP failure") <> 0) then
strMessage = strFQDN & " is unreachable.<br><br>"
strMessage = strMessage & "The host name you entered may not be valid<br>"
strMessage = strMessage & "or the remote client may be unable to respond.<br>"
ErrorExit(strMessage)
elseif (InStr(strLine, "SystemPowerstate is:") <> 0) then
if (InStr(strLine, "0") <> 0) or (InStr(strLine, "512") <> 0) then
strTMP = MyMessage(strFQDN & " is powered on...<br><br>",0,strDialogTitle,64 + 1)
elseif (InStr(strLine, "1") <> 0) then
ErrorExit(strLine)
elseif (InStr(strLine, "2") <> 0) then
ErrorExit(strLine)
elseif (InStr(strLine, "3") <> 0) then
ErrorExit(strFQDN & " is in sleep state...<br><br>")
elseif (InStr(strLine, "4") <> 0) then
ErrorExit(strFQDN & " is suspended...<br><br>")
elseif (InStr(strLine, "5") <> 0) then
strTMP = MyMessage(strFQDN & " is powered off...<br><br>",0,strDialogTitle,64 + 1)
else
ErrorExit(strLine)
end if
end if
loop
%>
</BODY>
</HTML>
<%
function MyMessage(strMessage,intTimeOut,strTitle,intButton)
Response.Write(strTitle & "<br>")
Response.Write(strMessage & "<br>")
ccsleep(intTimeOut)
MyMessage = 0
end function
function ErrorExit(strMessage)
if strMessage <> "" then
strTMP = MyMessage(strMessage,0,strDialogTitle & " - Error",16)
end if
' Unsuccessful end of script, exit the script
Response.End
end function
function ccSleep(seconds)
cmd = "%COMSPEC% /c ping -n " & 1 + seconds & " 127.0.0.1>nul"
objShell.Run cmd,0,1
end function
%>
Add comment