运行批处理时创建msgbox

时间:2016-03-24 11:08:48

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

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

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

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

1 个答案:

答案 0 :(得分:2)

尝试这样:

@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