cnblogs/dcrenl/批处理弹出提示及播放声音.html

39 lines
9.4 KiB
HTML
Raw Normal View History

2024-09-24 12:43:01 +08:00
<div id="sina_keyword_ad_area2" class="articalContent ">
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">一、弹出窗口</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1、msg命令</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">msg %username% "Hello"</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">2、mshta程序</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1利用vbsript的msgbox函数</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta vbscript:msgbox("Hello",64,"窗口 ")(window.close)</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">2利用vbscript的popup方法</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta vbscript:CreateObject("Wscript.Shell").popup("Hello ",7," 窗口",64)(window.close)</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">3利用javascript的alert方法</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta javascript:window.alert("Hello ");window.close()</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">4利用javascript的popup方法</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta "javascript:new ActiveXObject('WScript.Shell').popup('Hello',7,'窗口',64);window.close();"</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">5javascript的confirm方法</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta javascript:confirm("ha");window.close()</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">6javascript的execScript方法-- alert</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta vbscript:window.execScript("alert('hello world!');","javascript")</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">7javascript的execScript方法-- msgBox</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta javascript:window.execScript("msgBox('hello world!'):window.close","vbs")</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">8javascript的execute方法</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta vbscript:execute("msgbox ""one BOX"":msgbox ""two BOX"":window.close")</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">二、播放声音</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1. mshta程序</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">mshta vbscript:createobject("sapi.spvoice").speak("我是人!")(window.close)</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">&nbsp;</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">三、几点注意</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1 、ping -n 1 127.1&gt;nul</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1ping是测试网络连接性的网络命令参数"-n 1"表示只发送一次ICMPS数据包来测试网络的连接性。</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">2127.1表示本机保留IP地址实际就是127.0.0.1ping 127.1就表示ping 127.0.0.1可以测试网卡及TCP/IP协议是否正常安装及工作。</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">3"&gt;nul"表示把命令产生的屏幕显示信息重定向(&gt;)到空设备(nul)这样在屏幕上就没有显示ping命令的执行结果了。&gt;nul 是屏蔽标准输出在屏幕上的显示2&gt;nul 是屏蔽出错显示,&ldquo;&gt;nul 2&gt;nul &rdquo;是无论对错,都屏蔽屏幕显示。</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">在批处理中一般用来延时用,这也根本不是一个计时的命令,没法"显示计时",只是运行这条命令大约要1秒钟而已.. 可以简化写成ping -n 2 127.1 &gt;nul,还有两个0命令运行时会自动补上. &gt;nul是不显示ping命令执行结果信息. /n后面定义发送数据包的数量,发送2个包约用时1秒,不过这个时间不大精确.. 127.0.0.1是一个本机ip,不管是否有连网,只要电脑上有网卡这个ip就存在,常有人用这个ping命令来测试网卡是否完好..</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">2、控制</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1暂停批处理直接按键盘上的Pause键喽</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">2终止批处理组合键Ctrl+C。不过有时候它好像响应的不太积极啊&hellip;</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">四、 用户交互</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">1. color命令设置窗口背景色和字体颜色用color/?查看</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">2. mode命令设置窗口大小"MODE CON [COLS=c] [LINES=n]"cols即宽度lines即高度。</p>
<p style="margin: 0px 0px 5px; padding: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; color: #494949; font-family: simsun; background-color: #ffffff;">3. msg命令GUI交互窗口详细内容参见msg /?。</p>
</div>