2

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 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your response... Is there a way to do it in CMD instead of bash? It doesn't work in bash, because I am expecting to open a new cmd window after the last command...
well, some shell will have to be used, i think
Thank you very much sir for your help and time. I appreciate it.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.