0

I have a utility abc.exe that launches a special command prompt. By special I mean, certain environment variables are set on that prompt. Next I have to run a set of commands on this special command window. I have combined all such commands into a batch file and run this bat file. However, these are still 2 steps.

  1. Launch special command prompt through abc.exe(can be run through command line)
  2. Run commands.bat

I want to combine these 2 steps in single batch file such that, the commands.bat or rather the commands contained in that file are run on special command prompt only. Is this possible by somehow restricting/directing commands on a specific command prompt?

Now I do not have code for abc.exe, so only thing I can do with it is launch the special command prompt through it.

2
  • If this abc.exe tool have no command line switch (or some key in environment or .ini file) which allows to pass a batch file for execution to it and do not accept the input from std. input, the only way I see is to create a batch or script which starts the tool, waits for a special console (or detects it by a capture) and then sends your batch file to this console window char-by-char using sendkeys.
    – Akina
    Nov 6, 2018 at 7:28
  • @Akina you are right, I am looking for the way to "capture" the console window. Do you have an idea of how to do that? Nov 6, 2018 at 8:52

1 Answer 1

3

VBS script draft template (store as .VBS file).

Set WshShell = WScript.CreateObject("WScript.Shell") ' Create Shell object
WshShell.Run "abc.exe", 9                            ' Execute application
WScript.Sleep 500                                    ' Wait 0.5s for its start
WshShell.AppActivate "SpecialConsole"                ' Set focus to console window 
WshShell.SendKeys "MyScript.bat"                     ' Type batch file name
WshShell.SendKeys "{ENTER}"                          ' Press Enter key

Edit as you need.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .