EDIT
If you want to perform any task at computer startup or based on an event this is very helpful
Back to the question
I have two questions:
I want some specific commands to be executed when I start command prompt.
e.g. cls
to clear my command prompt.
I want to execute some commands in a batch file and wait for the user to enter new commands (if any).
e.g. A batch file which will take the user to some specified folder and then wait for the user to rename/delete a file from the command prompt.
How can I do it?
If you want a defined set of commands to run every time you start a command prompt, the best way to achieve that would be to specify an init script in the AutoRun registry value. Create it like this (an expandable string value allows you to use environment variables like %USERPROFILE%
):
reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^
/t REG_EXPAND_SZ /d "%"USERPROFILE"%\init.cmd" /f
Then create a file init.cmd
in your profile folder:
@echo off
command_A
command_B
...
cls
To remove these changes, delete the registry key:
reg delete "HKCU\Software\Microsoft\Command Processor" /v AutoRun