%@ LANGUAGE = "VBSCRIPT"%>
**** WELCOME TO THE CONTROL SCRIPT FOR ZAZA! ***
**** NOW CHECKING FOR OSINFO REQUEST ****
<%
if trim(Request.querystring("OSInfo")) <> "" then
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if
Service.Security_.ImpersonationLevel = 3
Set SystemSet = Service.InstancesOf("Win32_OperatingSystem")%>
**************** OPERATING SYSTEM INFO *****************
<%for each System in SystemSet%>
Name: <%=System.CSName%>
Description: <%=System.Description%>
Install Date: <%=mid(System.InstallDate, 5,2)%>/<%=mid(System.InstallDate, 7, 2)%>/<%=mid(System.InstallDate, 1, 4)%>
<%BootYear = mid(System.LastBootUpTime, 1, 4)
BootMonth = mid(System.LastBootUpTime, 5,2)
BootDay = mid(System.LastBootUpTime, 7, 2)
BootHour=mid(System.LastBootUpTime, 9, 2)
BootMin=mid(System.LastBootUpTime, 11, 2)
BootSec=mid(System.LastBootUpTime, 13,2)
BootHour = BootHour + 7 'Adjust for UTC offset
%>
Last Booted: <%=BootMonth%>/<%=BootDay%>/<%=BootYear%> at <%=BootHour%>:<%=BootMin%>:<%=BootSec%>
Caption: <%=System.Caption%>
Version: <%=System.Version%>
Windows Directory: <%=System.WindowsDirectory%>
Free Phys Memory: <%=System.FreePhysicalMemory/1024%> MB
Total memory: <%=System.TotalVisibleMemorySize/1024%> MB
Serial Number: <%=System.SerialNumber%>
Service Pack Version: <%=System.ServicePackMajorVersion%>.<%=System.ServicePackMinorVersion%>
Status: <%=System.Status%>
<%next
end if%>
**** NOW CHECKING FOR SERVICES REQUEST ****
<%
if trim(Request.querystring("Services")) <> "" THEN
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = locator.connectserver(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if
Service.Security_.ImpersonationLevel=3
Set ServiceSet = Service.InstancesOf("Win32_Service")%>
************** WINDOWS SERVICES LISTING *****************
<%for each Service in ServiceSet%>
<%=Service.Description%>
<%next
end if%>
**** NOW CHECKING FOR STARTSERVICE REQUEST ****
<%
if trim(Request.querystring("StartService")) <> "" then
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if
Service.Security_.ImpersonationLevel = 3
Set ServiceSet = GetObject("winmgmts:").ExecQuery("select * from Win32_Service where Name='Exhibit'")
for each Service in ServiceSet
RetVal = Service.StartService()%>
<%if RetVal = 0 then%>
Exhibit Service has been Started
<%end if
if RetVal = 10 then%>
Exhibit Service is Already Running
<%end if
next
%>
**************** Exhibit Services Start *****************
<%
end if%>
**** NOW CHECKING FOR STOPSERVICE REQUEST ****
<%
if trim(Request.querystring("StopService")) <> "" then
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = Locator.ConnectServer(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if
Service.Security_.ImpersonationLevel = 3
Set ServiceSet = GetObject("winmgmts:").ExecQuery("select * from Win32_Service where Name='Exhibit'")
for each Service in ServiceSet
RetVal = Service.StopService()%>
<%if RetVal = 0 then%>
Exhibit Service has been Stopped
<%end if
next
%>
**************** Exhibit Services Stop *****************
<%
end if%>
**** NOW CHECKING FOR RESTART REQUEST ****
<%
if trim(Request.querystring("Restart")) <> "" THEN
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = locator.connectserver(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if
Service.Security_.ImpersonationLevel = 3
Service.Security_.Privileges.AddAsString ("SeRemoteShutdownPrivilege")
Set OpSysSet = Service.InstancesOf("Win32_OperatingSystem")%>
********************** SYSTEM RESTART **********************
<%if err <> 0 then%>
Unable to obtain instance of Win32_OperatingSystem Object to perform restart!
<%err.clear
end if
for each OpSys in OpSysSet
if OpSys.Primary=True then
Opsys.Reboot
if err = 0 then%>
<%=Servername%> RESTART Successful!
<%else%>
RESTART failed!
<%err.clear
end if
END IF
Next
end if%>
**** NOW CHECKING FOR KILL REQUEST ****
<%
if trim(Request.querystring("Kill")) <> "" THEN
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = locator.connectserver(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if
Service.Security_.ImpersonationLevel = 3
Service.Security_.Privileges.AddAsString ("SeRemoteShutdownPrivilege")
Set OpSysSet = Service.InstancesOf("Win32_OperatingSystem")%>
********************** SYSTEM KILL **********************
<%if err <> 0 then%>
Unable to obtain instance of Win32_OperatingSystem Object to perform shutdown!
<%err.clear
end if
for each OpSys in OpSysSet
if OpSys.Primary=True then
Opsys.Shutdown
if err = 0 then%>
<%=Servername%> KILL Successful!
<%else%>
KILL failed!
<%err.clear
end if
END IF
Next
end if
%>
**** NOW CHECKING FOR PROCESSES REQUEST ****
<% 'Enumerate Processes on Remote System
if trim(Request.querystring("Processes")) <> "" THEN
Servername = trim(Request.querystring("server"))
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Service = locator.connectserver(Servername)
if err <> 0 then%>
Locator.ConnectServer Failed!
<%err.clear
end if %>
**************** PROCESS LISTING ********************
<% set objService = getobject("winmgmts:")
for each Process in objService.InstancesOf("Win32_process")%>
<%=Process.Handle%><%=Process.Name%>
<%next
end if
%>
<%
if trim(Request.querystring("LocalOS")) <> "" then
Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
for each System in SystemSet%>
Name: <%=System.CSName%>
Description: <%=System.Description%>
Install Date: <%=mid(System.InstallDate, 5,2)%>/<%=mid(System.InstallDate, 7, 2)%>/<%=mid(System.InstallDate, 1, 4)%>
<%BootYear = mid(System.LastBootUpTime, 1, 4)
BootMonth = mid(System.LastBootUpTime, 5,2)
BootDay = mid(System.LastBootUpTime, 7, 2)
BootHour=mid(System.LastBootUpTime, 9, 2)
BootMin=mid(System.LastBootUpTime, 11, 2)
BootSec=mid(System.LastBootUpTime, 13,2)
BootHour = BootHour + 7 'Adjust for UTC offset
%>
Last Booted: <%=BootMonth%>/<%=BootDay%>/<%=BootYear%> at <%=BootHour%>:<%=BootMin%>:<%=BootSec%>
Caption: <%=System.Caption%>
Version: <%=System.Version%>
Windows Directory: <%=System.WindowsDirectory%>
Free Phys Memory: <%=System.FreePhysicalMemory/1024%> MB
Total memory: <%=System.TotalVisibleMemorySize/1024%> MB
Serial Number: <%=System.SerialNumber%>
Service Pack Version: <%=System.ServicePackMajorVersion%>.<%=System.ServicePackMinorVersion%>
Status: <%=System.Status%>
<%next
end if%>
**** END OF SCRIPT! ****