0

I am trying to create a batch file (or some other file) to show a pop up reminder with a yes/no option that I can get set up to run at a designated time in task scheduler. This will be planned to run on basic computers so the end users will not have any major scripting software to run.

I need to set up a reminder for staff to check in each morning. If they select yes, I want it to just close the pop up, but if they check no, I want it to open up the website for them to check in.

I currently have a batch file with the following:

@echo off
del msgbox.vbs
echo x=msgbox("Reminder to sign in on School Checkin." ,4, "School Checkin Reminder") >> msgbox.vbs
start msgbox.vbs

So I can get it set up to show up with the yes/no option, but I would like it set up to when they press no, that it would open up the check-in site.

It does not need to be a batch file, but something that can at least run in the background without showing the commands and that can run through task scheduler.

3 Answers 3

0

Here is one way. You can use Microsoft HTA to make a simple dialog with a yes and no button on it. Your IT might not allow HTA but most do.

This is also very little code to do in c# but you would need to compile and distribute it.

What did you want the [Yes] button to do? I made it simply close the window.

I made it open the default browser window to DuckDuckGo.com .. I am sure that isn't what you will be doing.

I am not here for continual support to make it do EXACTLY what you want. I am giving you a starting point if it doesn't do what you want already. I am happy to answer questions but not author your solution if this isn't it. Perhaps your additions can be used to update this answer.

Pros:

  • Built in to windows
  • Web based GUI
  • Direct access to vbscript or javascript (jscript)

Cons:

  • You will see a flash when it opens.
  • Many more cons will show up in the comment section I am sure ;-)

To use it, save the text to a file called anything you like with a HTA extension.

Double click to run and pick "Microsoft (R) HTML Application Host"
To run from task scheduler (or a shortcut), It will be MSHTA <path_to_hta_file>

<!DOCTYPE html>
<html>
<head>
    <title>Reminder to sign in on School Checkin</title>
    <meta http-equiv="x-ua-compatible" content="IE=9">
    <meta name="author" content="Jeremy England">
    <meta name="copyright" content="SimplyCoded">
    <meta name="last-modified" content="2015-11-10">
    <hta:application
        border="thin"
        contextmenu="no"
        innerborder="no"
        icon="Narrator.exe"
        maximizebutton="no"
        minimizebutton="no"
        selection="no"
        singleinstance="yes" />

    <!--HTML APP SCRIPT-->
    <script type="text/vbscript">
' ---------
' On load
' ---------
 Sub window_onload()
  document.body.scroll = "no"
  window.moveTo 0,2000
  resizeWindow()
  window.moveTo 200,100
 End Sub
' ---------
' On Call 
' ---------
Class getWindowSize
 Function width()
 width = document.body.offsetWidth+16
 End Function
 Function height()
 height = document.body.offsetHeight+39
 End Function
 Function scrollHeight()
 scrollHeight = document.getElementById("tpArea").scrollHeight
 End Function
End Class

Set current = New getWindowSize

Function resizeWindow()
 ratio = 0.62
 wdth = current.width
 hght = current.width*ratio
 
 Do while current.height-50 <= current.scrollHeight
 If current.height >= screen.height-200 Or current.width >= screen.width-200 Then
  Exit Do
 Else
  wdth = wdth + 5
  hght = hght + 5*ratio
  window.resizeTo wdth, hght
 End If
 Loop
 
 Do while current.height-50 >= current.scrollHeight
 If current.height <= 155 Or current.width <= 250 Then
  Exit Do
 Else
  wdth = wdth - 5
  hght = hght - 5*ratio
  window.resizeTo wdth, hght
 End If
 Loop
End Function

' ---------
' On click
' ---------
 Function yesBtn()
   Window.Close()
 End Function

 Function noBtn()
  Set wsh=CreateObject("WScript.Shell")
  wsh.Run "http://duckduckgo.com"
  Window.Close()  
 End Function
    </script>


    <!--HTML APP STYLE-->
    <style>
        html, body {
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
            font-family: Arial;
            font-size: 10pt;
        }

        #tpArea {
            margin: 10px;
            padding-bottom: 60px;
        }

        #btArea {
            position: fixed;
            bottom: 0px;
            right: 0px;
            background-color: #ecf0f1;
            width: 100%;
            height: 50px;
            text-align: right;
        }

        button {
            font-family: Arial;
            font-size: 10pt;
            position: relative;
            top: 12.5px;
            right: 10px;
            width: 85px;
            height: 25px;
            margin-left: 5px;
            border: none;
            border-radius: 30px;
            background-color: #ffffff;
        }

            button:hover {
                color: #ecf0f1;
            }
    </style>
</head>


<!--HTML APP CONTENT-->
<body>
    <div id="tpArea">
        School Checkin Reminder
    </div>

    <div id="btArea">
        <button id="Ybtn" onclick="yesBtn()">Yes</button>
        <button id="Nbtn" onclick="noBtn()">No</button>
    </div>
</body>
</html>

Original Unmodified HTA came from here

0

Using your script,

  1. Add user input and and choice (see also Woude).
  2. Add the command to start the default browser, e.g., start <URL>.
0

Note that your prompt is not worded correctly: "Reminder to sign in on School Checkin" is not a yes/no question. Try "Did you sign in on School Checkin?"

So here is a "pure vbscript" option. Combines your existing snippet with a shell-object snippet from the HTA answer (the Function noBtn()). Wraps the "run command" in a test of the return value of the message box (vbNo is a vbscript defined constant).

dim wsh, x
x = msgbox("Did you sign in on School Checkin?" , 4, "School Checkin Reminder")
if x = vbNo then
    Set wsh = WScript.CreateObject("WScript.Shell")
    wsh.Run "http://duckduckgo.com", 1, false
end if

I tested it by running wscript test.vbs in a batch file. Presumably you can use this in a scheduler and avoid a batch file altogether, but you can echo this in the manner of your question example as it is compact.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .