I made my first foray into HTA's last night, and have a question. I'm building one that on startup queries AD to grab all computers running a server OS. Then populate a table, giving two buttons one for Shutdown, and one for Reboot. The shutdown and Reboot buttons, when clicked fire functions to use the Win32Shutdown.
It works fine, however, I want to build into the function a pop up window that will ask whether they really want to do it, and if the answer is yes, then run the shutdown/restart code, if not do nothing.
Here is the code for the functions, if you want more from the entire HTA let me know.
Code: Select all
Function RemoteReStart(strPC)
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Connection = Locator.ConnectServer(strPC, "rootcimv2")
'Get Win32_OperatingSystem objects - only one object In the collection
WQL = "Select Name From Win32_OperatingSystem"
Set SystemClass = Connection.ExecQuery(WQL)
'Get one system object
'I think there is no way To get the object using URL?
For Each System In SystemClass
System.Win32ShutDown (6)
Next
End Function
Function RemoteShutdown(strPC)
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Set Connection = Locator.ConnectServer(strPC, "rootcimv2")
'Get Win32_OperatingSystem objects - only one object In the collection
WQL = "Select Name From Win32_OperatingSystem"
Set SystemClass = Connection.ExecQuery(WQL)
'Get one system object
'I think there is no way To get the object using URL?
For Each System In SystemClass
System.Win32ShutDown (5)
Next
End Function
Any help is greatly appreciated. I know I can make a popup window, however, I'm not sure how to stop the code processing, and do the action I want depending on the answer. Thanks.
Cheers,
Ayth