SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to work with CMD prompt and prompt selections


How to work with CMD prompt and prompt selections

Author
Message
TeraByteMe
TeraByteMe
SSC Eights!
SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)

Group: General Forum Members
Points: 841 Visits: 589
I have an executable that when ran opens a cmd windows, gives some information, and then prompts for a selection at the prompt as show below:

"Would you like to proceed? [Y\N]"

I am trying to figure out how best to program the automation of a response of Yes via PowerShell. I have looked at Invoke-Cmd but not getting how I can use this in the way that I need things to work.

Any ideas?

Thanks!

A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
TeraByteMe
TeraByteMe
SSC Eights!
SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)

Group: General Forum Members
Points: 841 Visits: 589
This will execute the application but as a result it opens in a cmd window and how to make the default selection of Y (Yes) from the window? Note, the executable doesn't take parameters as input.

Start-Process -filePath "C:\DB Tools\DBCleaner\DbCleaner.exe"

A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)

Group: General Forum Members
Points: 217433 Visits: 41994
It sometimes depends on the executable, but I've had good luck with this problem in the past.

First, make a text file called Y.txt. It should contain 1 character. That character is "Y" without the quotes. Make sure that when you enter the character to press the [Enter] key after the "Y" in whatever editor you're creating the file in.

Then, when you execute the exe, include a redirected input from the Y.txt file. From a command prompt, it would look like the following...

C:\DB Tools\DBCleaner\DbCleaner.exe < C:\somepath\Y.txt


... where "C:\somepath\" is the actual folder that the Y.txt file lives in.

I don't know if "Start-Process -filePath" will handle such redirection, though.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
TeraByteMe
TeraByteMe
SSC Eights!
SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)

Group: General Forum Members
Points: 841 Visits: 589
That trick works with the exe that I just created will see if it works with the one I actually have to run it against. Thanks!

Jeff Moden (5/26/2012)
It sometimes depends on the executable, but I've had good luck with this problem in the past.

First, make a text file called Y.txt. It should contain 1 character. That character is "Y" without the quotes. Make sure that when you enter the character to press the [Enter] key after the "Y" in whatever editor you're creating the file in.

Then, when you execute the exe, include a redirected input from the Y.txt file. From a command prompt, it would look like the following...

C:\DB Tools\DBCleaner\DbCleaner.exe < C:\somepath\Y.txt


... where "C:\somepath\" is the actual folder that the Y.txt file lives in.

I don't know if "Start-Process -filePath" will handle such redirection, though.



A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)

Group: General Forum Members
Points: 217433 Visits: 41994
Thanks for the feedback. I'd be interested in knowing if it actually works on the one you wanted it to. Let me know, if yhou get the chance.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
TeraByteMe
TeraByteMe
SSC Eights!
SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)

Group: General Forum Members
Points: 841 Visits: 589
I tried every way icould think of to get it to work with get-process but no luck. I will let you know once i confirm.

Jeff Moden (5/27/2012)
Thanks for the feedback. I'd be i[font=][/font]nterested in knowing if it actually works on the one you wanted it to. Let me know, if yhou get the chance.


A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)

Group: General Forum Members
Points: 217433 Visits: 41994
Be advised that some of these apps just don't work this way. They sometimes require the human element to be present at just the right time.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
TeraByteMe
TeraByteMe
SSC Eights!
SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)

Group: General Forum Members
Points: 841 Visits: 589
The only way we could get this to work was to add a flag to the program that bypasses the prompt. Logical because you can't tell a program to do something that it hasn't been written to do, and the only alternative to the prompt seemed to be to send a key stroke to the console once it was there. Not practical at all.

A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)SSC Guru (217K reputation)

Group: General Forum Members
Points: 217433 Visits: 41994
I sure do appreciate you taking the time for the feedbback here. As a side bar, what you just said makes me real happy that I walked away from the front end world back in 2002. ;-)

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
TeraByteMe
TeraByteMe
SSC Eights!
SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)SSC Eights! (841 reputation)

Group: General Forum Members
Points: 841 Visits: 589
Smile I am thankful you appreciate it. It is all about the journey and learning out realistic limitation in it! Thank you for helping me along that journey!!

Jeff Moden (5/31/2012)
I sure do appreciate you taking the time for the feedbback here. As a side bar, what you just said makes me real happy that I walked away from the front end world back in 2002. ;-)


A clever person solves a problem. A wise person avoids it. ~ Einstein
select cast (0x5365616E204465596F756E67 as varchar(128))
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search