【问题标题】:Create msgbox when running batch运行批处理时创建 msgbox
【发布时间】:2016-03-24 11:08:47
【问题描述】:
@echo off
wmic csproduct get uuid
pause
wmic DISKDRIVE get SerialNumber
pause
getmac
pause

我需要每个人弹出自己的消息框,所以当我单击“确定”时,它会移动到下一个,然后是下一个。最后,它将所有内容保存为桌面上的文本文档。目前在.bat 中使用,但如果.vbs 更容易或更好,请告诉我要使用什么代码。

我尝试过包含 msgbox,但不确定如何为每个框设置不同的代码。我曾尝试逆向工程: Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId") 但没有这样的运气

【问题讨论】:

  • 不习惯告诉人们“使用什么代码”,希望您发布您尝试过的内容并尝试帮助您自己找到解决方案。
  • 所有有用的信息应该是added to最初的问题。
  • 我不明白,为什么点击yes 按钮比点击任何键更容易...

标签: batch-file vbscript uuid serial-number msgbox


【解决方案1】:

这样试试:

@echo off
Set Title="Example of MsgBox by Hackoo"
Set TmpFile=Tmp.txt
Set LogFile=%UserProfile%\Desktop\result.txt
(
    for /f "delims=" %%G in ('wmic csproduct get uuid') do (echo "%%G" & Call:MsgBox "%%G" ,vbInformation,%Title%)
    for /f "delims=" %%G in ('wmic diskdrive get SerialNumber') do (echo "%%G" & Call:MsgBox "%%G" ,vbInformation,%Title%)
    for /f "delims=" %%G in ('getmac') do (echo %%G & Call:MsgBox "%%G" ,vbInformation,%Title%)
)>%TmpFile%
Cmd /U /C Type %TmpFile% > %LogFile%
Start "" %LogFile%
Del %TmpFile%
Exit /b

:MsgBox <Message> <Buttons Type> <Title>
Rem This function create a vbscript file %tmp%\Msg.vbs with 3 arguments and executes it
Rem First argument is %1 ==> To show the message
Rem Second argument is %2 ==> To choose the type of buttons
Rem Third argument is %3 ==> To show the Title
Rem Example how we can call this function :
Rem Call :MsgBox "This an example from Hackoo to say Hello to ""stackoverflow.com"" ",vbInformation,%Title%
Rem Call :MsgBox "This an example from Hackoo to show any kind of a Warning Message",vbExclamation,%Title%
Rem Call :MsgBox "This an example from Hackoo to show any kind of error",vbCritical,%Title%
(
echo MsgBox %1,%2,%3
)>%tmp%\Msg.vbs
cscript /nologo %tmp%\Msg.vbs
Del %tmp%\Msg.vbs

【讨论】:

  • 再一次没有任何解释......好吧,msg.vbs 会做什么对我们来说可能很明显,但不是所有人。
  • @Lankymart 嗯,我想我知道谁对我所有的答案投了反对票 :)
  • 我什么都没投反对票,你在说什么?然而,我确实认为您的一些答案虽然在技术上是正确的,但缺乏详细的解释。
  • @Lankymart 我编辑我的答案并发表评论,别忘了这次投票! (-_°) 谢谢你的公平竞争!
  • 好的,除去几个空的消息框,这段代码确实可以很好地工作。我对编码知之甚少,我通常只是保存样本并弄乱它们。谢谢!!
猜你喜欢
  • 2016-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多