How to create a script automating CMD(command prompt) and line of commands

Viewed 1405

I would like to create a shell script that automatically open the CMD and type 2 lines of command

This is the herierchy

  1. open CMD
  2. Change directory (cd d:\mydirectory\drivers
  3. command ( file.exe start -c )

I tried some examples in the existing posts but it has different ways like editing regedit/run at start up..

What I need is to create a executable file wherein if I click it, it will automatically open cmd and type those commands.

I am not also familiar nor knowledgeable in creating shell scripts.

Hope someone will help. Thank you in advance.

2 Answers

Why do you need to specifically open CMD?

Just create a file, call it script.sh, as follows:

#!/bin/bash

cd d:\mydirectory\drivers
file.exe start -c

Save the script and to make it executable, run chmod +x script.sh

Now, you can run it by just clicking on it.

Alright, I found a solution already. Thank you very much for your time.

I just put these command (step-2 and 3) in notepad

then save as textfile.cmd

Related