I've searched long and hard to get details on this, with no luck.
All I want to do is:
- open CMD
- change my working directory
- enter a text string command, and pause there so I can manually enter the last portion of the command and press enter
Example:
@ECHO OFF
start cmd.exe /K "cd C:\ProgramData\Microsoft\Windows\Start Menu"
I have the first half of it working fine, it opens cmd and changes the directory - but how do I fill in the text string into the window at this point?
Ok, you want to:
- open CMD
- change my working directory
- enter a text string command, and pause there so I can manually enter the last portion of the command and press enter
And then? After that there are two cmd.exe sessions active, so it will be problems with the following input. The Batch file below allows you do to what you want, but have the problem of what to do next. Try it and give feedback, so we can fix the details.
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
rem Start cmd.exe program
start "" cmd
rem Send whatever you want to previous cmd.exe
%SendKeys% "echo Hello world!{ENTER}"
%SendKeys% "cd C:\ProgramData\Microsoft\Windows\Start Menu{ENTER}"
%SendKeys% "echo You continue at this point: "
set /P "="
ECHO TERMINATE ORIGINAL BATCH
goto :EOF
@end
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
Try this:
@ECHO OFF
set /p "txt=Enter Path"
start cmd.exe /K "cd /d %txt%"