1.

Solve : question prompts in batch file then continue batch?

Answer»

I am trying to make a command in a batch file to ask if you want to run a program and if you SAY Y then it will launch it BUT IF YOU SAY N it wont launch it and it will continue down to the next question.

for example:

echo "do you want to run cleanrp.vbs? enter Y or N

if Y then

start cleanrp.vbs

(if no then run the batch will echo the next question for the next program)

TIMEOUT 10
Do you wants breaks?
A break is where only on choice is done and then skips over all other items you have.
Or you can use the ELSE statement.

IF blah-blah  (
    twiddle-doom.
    )  ELSE  (
       IF blah-blah-blah  (
           twiddle-doom-doom.
          )  ELSE   (
                echo Never Mind!
               )
 well ive TRIED it now in c++ INSTEAD of the batch but i get stuck when loading the program.
 (* i would like to load the program from the root of any drive letter wherever it is for example the root of my flash drive and then a folder and ANOTHER folder and then the program*)

WHEN I RUN IT IT SAYS CANNOT FIND PATH SPECIFIED

here is the c++ code.. This thread might now have to be moved im not sure:



#include
#include
using namespace std;

int main() {
string x, y, n;
   
cout<< "Run dial a fix? Enter Y or N ";

cin>>x;
   
   if (x == "y")
   
   {   

system ("\"%SystemRoot\\AUTO VIRUS REMOVAL\\kroot.exe");  // WHEN I RUN IT IT SAYS CANNOT FIND PATH SPECIFIED
   }
   
   if (x == "n")
   cout<< "Run winsock reset? Enter Y or N ";  // this is the prompt for next program if entered "n"
   

   return 0;
   
}
QUOTE from: bigbutt100 on December 07, 2010, 06:04:14 PM

system ("\"%SystemRoot\\AUTO VIRUS REMOVAL\\kroot.exe");  // WHEN I RUN IT IT SAYS CANNOT FIND PATH SPECIFIED

did you mean %SystemRoot%  ?

Also, I don't think the C run-time will expand the environment variable for you. Quote from: BC_Programmer on December 08, 2010, 12:51:59 AM
Also, I don't think the C run-time will expand the environment variable for you.

There is a function called getenv that will retrieve env vars
Quote from: Salmon Trout on December 08, 2010, 10:17:08 AM
There is a function called getenv that will retrieve env vars

yes, but what I meant was the system() call would try to execute the name as provided, without expanding environment variables.


Any time I see a system() call in C I shudder because oftentimes that means the program would have been better suited to be written in a scripting language. Quote from: BC_Programmer on December 08, 2010, 10:27:36 AM
Any time I see a system() call in C I shudder because oftentimes that means the program would have been better suited to be written in a scripting language.

This one certainly looks that way.


Discussion

No Comment Found