Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to work with CMD prompt and prompt selections Expand / Collapse
Author
Message
Posted Friday, May 25, 2012 6:01 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 5, 2014 12:52 PM
Points: 158, Visits: 544
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!
Post #1306873
Posted Friday, May 25, 2012 6:16 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 5, 2014 12:52 PM
Points: 158, Visits: 544
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"
Post #1306880
Posted Saturday, May 26, 2012 1:06 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:50 PM
Points: 36,711, Visits: 31,159
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1307000
Posted Sunday, May 27, 2012 6:11 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 5, 2014 12:52 PM
Points: 158, Visits: 544
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.

Post #1307099
Posted Sunday, May 27, 2012 9:11 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:50 PM
Points: 36,711, Visits: 31,159
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1307108
Posted Monday, May 28, 2012 5:51 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 5, 2014 12:52 PM
Points: 158, Visits: 544
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.
Post #1307478
Posted Tuesday, May 29, 2012 6:16 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:50 PM
Points: 36,711, Visits: 31,159
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1307712
Posted Thursday, May 31, 2012 8:03 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 5, 2014 12:52 PM
Points: 158, Visits: 544
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.
Post #1309457
Posted Thursday, May 31, 2012 8:30 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 2:50 PM
Points: 36,711, Visits: 31,159
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1309459
Posted Thursday, May 31, 2012 8:46 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 5, 2014 12:52 PM
Points: 158, Visits: 544
:) 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.
Post #1309464
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse