Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Maverick
- Posts: 3
- Joined: 27 Mar 2023 09:49
#1
Post
by Maverick » 28 Mar 2023 19:56
I need to open up the command shell within a very specific directory, let's say "C:\My Project". I did a little bit of searching on the internet and found a very simple batch file.
This works fine but I need to have the letters "fc.exe" typed at the command prompt as soon as the command shell opens. I tried the following:
Start cmd.exe /k "fc.exe "
The problem with this is that it executes the fc.exe command. That's no good. The program needs arguments or parameters to run so running fc.exe by itself produces nothing.
Any solutions?
-
Aacini
- Expert
- Posts: 1913
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#2
Post
by Aacini » 30 Mar 2023 12:49
Mmm... Think a minute about this request:
"Issue a command but not have it execute" Makes this any sense to you? (neither for me).
This phrase makes more sense:
"have the letters "fc.exe" typed at the command prompt"
At
this SO answer there is the solution to a request similar to yours:
I would like to know how to automate an input of data.
This is the
simplified solution:
Code: Select all
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
rem Send the keys...
%SendKeys% "fc.exe "
rem ... and run cmd.exe
cmd.exe
goto :EOF
@end
// JScript section
WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));
It works! (just tested)
Antonio