简体   繁体   English

运行批处理时创建msgbox

[英]Create msgbox when running batch

@echo off
wmic csproduct get uuid
pause
wmic DISKDRIVE get SerialNumber
pause
getmac
pause

I need each one to pop its own message box, so when I click OK it moves to the next one and then the next one.我需要每个人都弹出自己的消息框,所以当我单击“确定”时,它会移动到下一个,然后再移动到下一个。 At the end it saves all as a text document on the desktop.最后,它将所有内容保存为桌面上的文本文档。 Currently being used in a .bat but if .vbs would be easier or better please tell me what code to use.目前正在.bat中使用,但如果.vbs会更容易或更好,请告诉我使用什么代码。

I have tried including msgbox, but not sure how to set the different codes with each box.我试过包含 msgbox,但不确定如何为每个框设置不同的代码。 I have tried to reverse engineer: Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId") But no such luck我试图逆向工程: Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\DigitalProductId") 但没有这样的运气

Try like this way :像这样尝试:

@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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM