Computer Hope

Microsoft => Microsoft DOS => Topic started by: malshika on September 20, 2009, 02:14:15 AM

Title: Auto run .exe file and answer yes to questions
Post by: malshika on September 20, 2009, 02:14:15 AM
i have a .exe program i have to run this program automatically. So i can run this .exe file by creating a bat file and  schedule windows scheduler, no problem about that. But when i am running this .exe file it prompt a question would you like to continue this program How can i set yes to this .exe file?

Using the .bat file how to automate this process?
Title: Re: Auto run .exe file and answer yes to questions
Post by: Helpmeh on September 20, 2009, 05:11:22 AM
I don't think this is possible unless it has a switch to suppress prompting.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 06:03:32 AM
What is the exe file and how does it ask the question? Does it show a "yes" button? Or "Yes" and "No" buttons? More details please!
Title: Re: Auto run .exe file and answer yes to questions
Post by: malshika on September 20, 2009, 06:28:35 AM
its is a third party product software. i want to take backup using windows scheduler.
i am running (pdm_backup -d -f filename )  as a command then it prompt would u like to continue (y/n):
if i can enter 'y " using a bat file it is great. it will run the backup normally when i enter "y"  .

thanks if anybody can help to resolve this poblem great.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 06:31:33 AM
you could try using a pipe and passing the y through it like this

echo Y | pdm_backup -d -f filename

or

"redirection" from a file

echo Y>y.txt
Y.txt<pdm_backup -d -f filename
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 06:48:00 AM
[UPDATE]

The pipe technique is recommended in this thread here

http://www.helpdeskusers.com/e107_plugins/forum/forum_viewtopic.php?14393

Although they use single quotes around the Y (dunno why) so I suggest trying with and without quotes

Code: [Select]
echo 'Y' | pdm_backup
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 06:49:14 AM
.
Title: Re: Auto run .exe file and answer yes to questions
Post by: malshika on September 20, 2009, 06:52:28 AM
Great.Thank you salmon using the first suggestion i am able to take backup without quotes.

Thanks again.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 06:58:02 AM
Great.Thank you salmon using the first suggestion i am able to take backup without quotes.

Thanks again.

You are very welcome.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Helpmeh on September 20, 2009, 06:58:31 AM
Nice triple-post salmon.

So, the piped output goes to the first user input, in this case, a confirmation. Is there a way to make it go to the second?

Like for my first user-input, I need to say start, then for the second, it needs to say Y, just like the OP.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 07:02:58 AM
Nice triple-post salmon.

It's because they changed the buttons around. I intend to hit "modify" and hit "quote" by mistake, and cannot afterwards delete it.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 07:04:47 AM
So, the piped output goes to the first user input, in this case, a confirmation. Is there a way to make it go to the second?

Like for my first user-input, I need to say start, then for the second, it needs to say Y, just like the OP.

need more info; like what kind of program, and how you are running it etc.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Helpmeh on September 20, 2009, 07:27:03 AM
It used to be a batch file, now its an EXE. 

It basically asks you to begin, it sorts the files then asks you if you want to delete the originals (it copies the files, not moves).
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 07:33:11 AM
It used to be a batch file, now its an EXE. 

In that case, I'd rewrite and recompile the batch. Perhaps using passed parameters %1, %2, etc. Piping only works for the first prompt which takes characters from STDIN.
Title: Re: Auto run .exe file and answer yes to questions
Post by: macdad- on September 20, 2009, 03:21:33 PM
Besides piping, you cant send keys to an exe.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Helpmeh on September 20, 2009, 03:24:02 PM
Except with %1, %2, etc. anyway, no biggie.
Title: Re: Auto run .exe file and answer yes to questions
Post by: macdad- on September 20, 2009, 03:25:05 PM
Except with %1, %2, etc. anyway, no biggie.

That's with batch files, not exe's.
Title: Re: Auto run .exe file and answer yes to questions
Post by: Helpmeh on September 20, 2009, 03:27:24 PM
Batch files converted to exe?
Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 03:32:54 PM
Besides piping, you cant send keys to an exe.

If it is a console .exe which takes input from stdin, you can sometimes redirect stdin like this

program.exe < input.txt

Title: Re: Auto run .exe file and answer yes to questions
Post by: Salmon Trout on September 20, 2009, 03:33:37 PM
Batch files converted to exe?

Exactly.
Title: Re: Auto run .exe file and answer yes to questions
Post by: macdad- on September 21, 2009, 03:10:55 PM
Well yes, but still haven't checked into Batch-To-Exe, from prior testing it had a few bugs.