Running batch file

May 23, 2010 at 00:57:51
Specs: Microsoft Windows Vista Home Premium, 1.833 GHz / 3061 MB

I have a batch file (co.bat). I added it as a context menu option to Windows Explorer
. However, I want to run it in an ALREADY open instance of the command prompt, rather than open a new command prompt.

Unfortunately, cmd.exe (in Windows Explorer) always opens a new command prompt.

Is there a way I can run a batch file from Windows explorer in a command shell that is already open, and NOT a new one?

See More: Running batch file

Report •

May 23, 2010 at 12:33:10
since cmd will only read from one input (standard input unless redirected), I don't think there's a direct way to do what you want.
What you need is a "reverse Tee": a thing that would allow one application (cmd.exe)
to read input from two sources. You might google and actually find one!
Another means i tried, but i'm not sure if it will work for you, using vbscript:
'----- begin: kicker.vbs
dim wsh
set wsh=createobjec("")
wsh.appactivate "cmd"
wsh.sendkeys "mybat~"
'----- end vbscript
save the vbs, then make your shortcut with content:
cscript kicker.vbs
the vbs script will "kick in" the batchfile inside the cmd window.
Although it looks like another cmd instance is created (taskbar, blackscreen flash),
the workings and output etc. appear to take place in the existing cmd window.
Note if more than one cmd window might be running at a given time, you will have to
make arrangements to distinguish them, either by titling the window:
c:\>title "UseThisOne"
or using the psid instead of "cmd" at wsh.appactivate statement: wsh.appactivate "1264"

Report •
Related Solutions

Ask Question