Msgbox buttons

Iamnotageek

Expert Member
Joined
Dec 22, 2013
Messages
3,825
Reaction score
2,196
Hi guys,

Here's the code I have in notepad that runs before my little backup does in a .bat file I made...

echo msgbox "Please make sure you have plugged in the external hard drive before continuing & that ALL documents have been saved and closed." > %temp%\popup.vbs
wscript.exe "%temp%\popup.vbs
@echo off
cls
cd\
d:
robocopy d:\documents \\server-pc\users\public\dailynew /E
echo msgbox "All Done!" > %temp%\popup.vbs
wscript.exe "%temp%\popup.vbs

I just run the .bat file from within command prompt in Windows 10.

What I want:

Is there anyway to "code" or add a YES & NO button to that popup window before the backup starts?
 
Gentlemen, I thank you.

Below is with specific reference to the following code....

Code:
@echo off

    call :MsgBox "Would you like to go to URL?"  "VBYesNo+VBQuestion" "Click yes to go to URL"
    if errorlevel 7 (
        echo NO - don't go to the url
    ) else if errorlevel 6 (
        echo YES - go to the url
        start "" "http://www.google.com"
    )

    exit /b

:MsgBox prompt type title
    setlocal enableextensions
    set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
    >"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"
    set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
    endlocal & exit /b %exitCode%

I'm not very good at coding... Where would I insert my personalised code questions?

I would like a pop up that asks...

"Is the external hard drive plugged in?

Yes then start my backup from the @Echo off part ( Not sure where my backup code would go ).

If NO then quit.

I'm not sure how to do that. :crying:
 
Last edited:
Hope it works had to write this on my phone havent worked with batch in a while.

Bash:
@echo off


    call :MsgBox "Is the external HDD pluged in"  "VBYesNo+VBQuestion" "Click yes to go to continue"

    if errorlevel 7 (

        echo NO

    ) else if errorlevel 6 (

        echo YES

cls

cd\

d:

robocopy d:\documents \\server-pc\users\public\dailynew /E

echo msgbox "All Done!" > %temp%\popup.vbs

wscript.exe "%temp%\popup.vbs

    )


    exit /b


:MsgBox prompt type title


    setlocal enableextensions


    set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"


    >"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"


    set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul


    endlocal & exit /b %exitCode%
 
Top
Sign up to the MyBroadband newsletter
X