msgbox donotshowagain

Aug 9, 2009
293
1
Code:
setlocal

comment
simplified Having trouble unsetting the msgbox_checkbox IV after batch has completed
endcomment

echo %_date %_time %_msgbox_checkbox

gosub test
    
echo %@time[%_time]
echo.
gosub test


echo %@date[%_date]

goto end

:test
: # I only want to see the msgbox once during the batch
: # remming next line seems to be the only way to rest it
if %_msgbox_checkbox == 1 return
msgbox /M /Pc /I /1 OK DONOTSHOWAGAIN "simple test" How to reset the internal varible^nRunning the script a second time commenting out^nthe above return, it seems is the only way of resting^nthe IV %_msgbox_checkbox varible

return

:end
    :# I would of thought this would do it
    unset _msgbox_checkbox
endlocal
 
It would seem that, in order to reset the "Do Not Show Again", another MsgBox has to be called, without the DONOTSHOWAGAIN option.
Code:
@setlocal
@echo off
msgbox /M /Pc /I /1 OK DONOTSHOWAGAIN "simple test" How to reset the internal varible^nRunning the script a second time commenting out^nthe above return, it seems is the only way of resting^nthe IV %_msgbox_checkbox varible
echo _msgbox_checkbox: %_msgbox_checkbox
msgbox /T1 yesno "Copy" Copy all files to A:?
echo _msgbox_checkbox: %_msgbox_checkbox
endlocal
In the above example, note that I am using the /T1 option for MsgBox, which waits one second for a response, and then closes.

Just don't click the MsgBox, and it goes away, resetting _msgbox_checkbox to 0.

There is probably a better solution than mine.

Joe
Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  28.02.18 x64   Windows 10 [Version 10.0.19043.1526]
 
Along with the /T1 option, the MsgBox can be hidden, emulating a one second delay to the user;
Code:
msgbox /D1 /P-1000,-1000 /T1 yesno "Copy" Copy all files to A:?

Note that I have made the screen co-ordinates for the MsgBox negative, placing the window off of the screen while waiting for the /T1 second to pass.

Joe
 
Aug 9, 2009
293
1
Thank you Joe, I'll use the negative option.

unset _msgbox_checkbox would've been so much easier to write in scripts
 
May 20, 2008
11,843
120
Syracuse, NY, USA
What's the problem if it stays 1?
The only problem I see is that if you run the BTM a second time, you don't see the message box at all. So use your own variable (which will disappear after the BTM because of the SETLOCAL).

Code:
:test
if "%mb_dont_show" == "1" return
msgbox /M /Pc /I /1 OK DONOTSHOWAGAIN "simple test" foo
set mb_dont_show=%_msgbox_checkbox
return

You probably shouldn't rely on _msgbox_checkbox. What if you had several message boxes?
 
  • Like
Reactions: Kachupp
Aug 9, 2009
293
1
The only problem I see is that if you run the BTM a second time, you don't see the message box at all. So use your own variable (which will disappear after the BTM because of the SETLOCAL).

Code:
:test
if "%mb_dont_show" == "1" return
msgbox /M /Pc /I /1 OK DONOTSHOWAGAIN "simple test" foo
set mb_dont_show=%_msgbox_checkbox
return

You probably shouldn't rely on _msgbox_checkbox. What if you had several message boxes?
That's nice and simple thank you vince