【问题标题】:Windows 8.1 prompt for user actionWindows 8.1 提示用户操作
【发布时间】:2015-07-30 11:03:10
【问题描述】:

有没有办法使用 bat 文件来创建这样的提示?

...哪个有一个或多个用户可以点击的按钮,哪个会根据选择执行代码?

如果bat文件出来了,用其他方法怎么办?

【问题讨论】:

  • powershell 可以创建带有选项的弹出窗口,似乎不适用于(普通)批处理或 powershell。
  • 说实话,我对 Powershell 的了解为零。只有当它可以创建如上所示的提示时,我才愿意学习。如果只是普通的Frame,那我宁愿用自己熟悉的编程语言来做。
  • 您无法从批处理文件中提示 UAC 提升,但您可以调用 VBScriptPowershell 脚本来提示提升,然后重新运行批处理文件。
  • 我不会尝试进行 UAC 提升...除非您说创建上面显示的提示需要这样做。

标签: windows batch-file windows-8.1


【解决方案1】:

喜欢这个吗?

这是创建先前输出的批处理文件;使用 .bat 扩展名复制它:

<!-- :: 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>

有关此程序中使用的方法和其他示例的进一步说明,请参阅this post

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-25
    • 1970-01-01
    • 2015-03-19
    • 2020-01-17
    • 2014-11-04
    • 1970-01-01
    • 2015-05-25
    相关资源
    最近更新 更多