首页 文章

运行批处理时创建msgbox

提问于
浏览
-2
@echo off
wmic csproduct get uuid
pause
wmic DISKDRIVE get SerialNumber
pause
getmac
pause

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

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

1 回答

  • 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
    

相关问题