0

Is there a way to use a bat file to create a prompt like that?

enter image description here

...Which has one or more buttons that the user can click on, which would execute code depending on the choice?

If bat file is out, how to do it using other methods?

theAnonymous
  • 1,701
  • 2
  • 28
  • 62
  • powershell can create popup windows with options, doesn't seems to be posible with (plain) batch or powershell. – Octal Jul 28 '15 at 12:55
  • To be honest, I have zero knowledge on Powershell. I am willing to learn only if it can create the prompt as shown above. If it's just a normal Frame, then I would rather use a programming language that I am familiar with to do it. – theAnonymous Jul 28 '15 at 13:12
  • You can't prompt for UAC elevation from a batch file, but you can call a [VBScript](http://winhelponline.com/articles/185/1/VBScripts-and-UAC-elevation.html) or [Powershell](http://stackoverflow.com/questions/1566969/showing-the-uac-prompt-in-powershell-if-the-action-requires-elevation) script that will prompt for elevation and then rerun the batch file. – Tim Jul 28 '15 at 13:27
  • I am not trying to do an UAC elevation... unless you are saying that the creation of the prompt shown above requires that. – theAnonymous Jul 28 '15 at 13:51

1 Answers1

6

Like this one?

HTA input form example

This is the Batch file that created previous output; copy it with .bat extension:

<!-- :: Batch section
@echo off
setlocal

cls
echo Install Windows 8.1?
for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "HTAreply=%%a"
echo Reply: "%HTAreply%"
goto :EOF
-->


<HTML>
<HEAD>
<HTA:APPLICATION BORDER="none" SCROLL="no" >

<SCRIPT language="JavaScript">
window.resizeTo(1100,200);

function closeHTA(reply){
   var fso = new ActiveXObject("Scripting.FileSystemObject");
   fso.GetStandardStream(1).WriteLine(reply);
   window.close();
}

</SCRIPT>
<style type="text/css">
body { 
   margin-left: 10%; 
   margin-right: 10%; 
   color: white;
   background: #000099;
   font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
}
</style>
</HEAD>
<BODY>
   <h1>Get Windows 8.1 for free</h1>
   <p>Go to the Store to see what's new and get the update. You can keep using your PC while it downloads.<br><br>
   <div align="right">
   <button onclick="closeHTA('Yes');">Go to the Store</button>&nbsp;
   <button onclick="closeHTA('No');">No thanks</button>
   </div>
</BODY>
</HTML>

For a further description on the method used in this program and additional examples, see this post.

Aacini
  • 65,180
  • 12
  • 72
  • 108