Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Running a batch command from TaskDialog

Jul
14
0
i wish to run a batch file called pia.bat (which is in the path) after clicking on the yes from a TaskDialog that looks like this:


taskdialog yes no "PIA" "Run Pia.bat"
if %_? == 10 pia.bat

Running pia.bat from [C:\Program Files\JPSoft\TCMD31] works fine. Also works fine from windows command line.

How does one run a batch file from a yes no TaskDialog ?
 
It works here in a no-frills example. What happens in your case?

Code:
v:\> which echofoo.bat
echofoo.bat is a batch file : D:\uty\echofoo.bat

v:\> echo %@word[";",0,%path]
d:\uty

v:\> type d:\uty\echofoo.bat
echo foo

v:\> taskdialog yes no "xxx" "xxx"

v:\> if %_? == 10 echofoo.bat
foo
 
Looks like you have the basic logic right. If you want to call the secondary batch file and then return to the original, use the CALL command:

Code:
taskdialog yes no "PIA" "Run Pia.bat"
if %_? == 10 call c:\path\to\pia.bat

If you want to run the secondary batch file in a separate shell, use START:

Code:
taskdialog yes no "PIA" "Run Pia.bat"
if %_? == 10 start /pgm "%_cmdspec" /c "c:\path\to\pia.bat"
 
I see now if I paste the fist line in tcc and enter I get the task dialog to appear. After clicking yes, I then need to paste this line, if %_? == 10 call c:\path\to\pia.bat to get the batch file to execute.

How do I get the batch file to execute immediately after clicking the yes box?
 
Put both lines in a batch file, and then run the batch file.

Or, if you really want to do this from the command line, put both commands on the same line with an ampersand between them:
Code:
taskdialog yes no "PIA" "Run Pia.bat" & if %_? == 10 call c:\path\to\pia.bat
 
I want to create a simple menu with a button such that if the a button is clicked it will run a batch file. Is that possible in TCC?
 
It looks to me like you've got it already. What's wrong with what you have now?
 
Perform a search of this forum for the word;

TaskDialog

Here's a post I made several years ago involving TaskDialog;

There are also many other posts in regards to TaskDialog.

Joe
 
Using msg box I this works:

msgbox yesno "Ping Google" Ping 8.8.8.8? & if %_? == 10 ping 8.8.8.8

How do one configure the message box to stay open and on top after running once? I wish to use this as a menu for batch files I will be using on a regular basis.
 
Last edited:
This will do what you want;
Code:
do forever (msgbox yesno "Ping Google" Ping 8.8.8.8? & if %_? == 10 ping 8.8.8.8) & enddo

You will have to use Windows Task Manager to kill this.

A better option may be to follow my previous suggestion;

Joe
 
Using msg box I this works:

msgbox yesno "Ping Google" Ping 8.8.8.8? & if %_? == 10 ping 8.8.8.8

How do one configure the message box to stay open and on top after running once? I wish to use this as a menu for batch files I will be using on a regular basis.

You want the message box to stay open when you click on OK? That's not how dialog boxes generally work. It would be possible, certainly, but you'd have to control the dialog's message loop yourself. I don't think you could do it with just a batch file; you'd need to write your own dialog box in a programming language like C++.
 

Similar threads

Back
Top