Using a .bat file, is it possible to write/send a command to DOS prompt ?
For instance, I want to type DIR command (without executing it) unless user press enter (or maybe he could delete the DIR command and type something else)
c:>DIR
Using a .bat file, is it possible to write/send a command to DOS prompt ?
For instance, I want to type DIR command (without executing it) unless user press enter (or maybe he could delete the DIR command and type something else)
c:>DIR
You can easyly write to the screen and read what user enters on keyboard. But what you ask is simulating user keyboard action.
It is of course possible, but not with simple batch command. You will have to use wshshell or powershell for that. Here is an example using PowerShell A simple PowerShell script to send keys to an application windows|InVista.
@if (@CodeSection == @Batch) @then
@echo off
CScript //nologo //E:JScript "%~F0"
goto :EOF
@end
WScript.CreateObject("WScript.Shell").SendKeys("DIR");
For further details, see this answer