Pop Up Confirm Window

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 16 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ayth
Posts: 10
Last visit: Mon Nov 26, 2007 8:51 pm

Pop Up Confirm Window

Post by ayth »

Hey All,


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
User avatar
abqbill
Posts: 138
Last visit: Mon Sep 28, 2020 1:20 pm

Pop Up Confirm Window

Post by abqbill »

Hi ayth,I'm not much help with VBScript in HTAs (I believe JScript is much more suitable for HTAs), but my approach would be to use the window object's confirm method.HTH,Bill
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Pop Up Confirm Window

Post by jvierra »

In an HTA yo can use the MsgBox function and set it's properties to display "yse,No,Cancel" and many othger buttons. This is the easiest method in eoither vbscript or jscript.

See vbscript documentation for a complete list of options for "MsgBox"

User avatar
abqbill
Posts: 138
Last visit: Mon Sep 28, 2020 1:20 pm

Pop Up Confirm Window

Post by abqbill »

Hi jvierra,The MsgBox function is specific to VBScript. In JScript, you can use the window object's confirm method. Another option is to call the showModalDialog method.Regards,Bill
User avatar
lehayes
Posts: 20
Last visit: Thu Mar 06, 2008 7:31 am

Pop Up Confirm Window

Post by lehayes »

Here is the code for the functions, if you want more from the entire HTA let me know.


I would be interested in your finished product. Looks useful in our lab.
This topic is 16 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked