2

This might be very basic but I cannot find the answer in the internet.

I have a cmd/bat file with 3 basics lines to set the working directory as the one of the current folder.Once I run it, I get the CMD window, and I type specific commands (example : "start notepad").

%~d1
cd "%~p1"
call cmd

What should I write within the cmd. or bat. file so the "start notepad" will be already launched as command?

Thank you very much

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
Arkadi w
  • 129
  • 22
  • Do you want cmd and notepad to be opened at the same time? – SomethingDark Jul 12 '15 at 18:02
  • Yes, as an example. I also use R (which is correctly configured in path) from cmd. So I have to type manually R and press Enter. I would like to avoid that kind of "typing" – Arkadi w Jul 12 '15 at 18:06

2 Answers2

0

Try this:

@echo off
Command.Com

When you'll open this batch file it will open up CMD where you can start typing commands like start notepad etc...I think this was what you was looking for?

0m3r
  • 12,286
  • 15
  • 35
  • 71
Wishaal Khan
  • 135
  • 7
  • He can already open cmd from a batch file. He wants to open a different program. – SomethingDark Jul 12 '15 at 18:12
  • What do you think the `Command.Com` is? `'command.com' is not recognized as an internal or external command, operable program or batch file.` – JosefZ Jul 12 '15 at 20:41
0

There are a couple of ways you can achieve this. You can open notepad directly with the start command and then run cmd, like this:

@echo off
%~d1
cd "%~p1"
start "" notepad
call cmd

You can also include the notepad start command directly in the cmd call, like this:

@echo off
%~d1
cd "%~p1"
call cmd /k start "" notepad

Note that there is a "" after start because start considers the first set of quotes that it encounters to be the window's title.

SomethingDark
  • 13,229
  • 5
  • 50
  • 55
  • Almost there. Actually the %~d1 cd "%~p1" is useless. Would like to the same for a basic R code. call cmd /k R now I want automatically the second line which after running R will run automatically source("myfile.R") How can I achieve this? Thank you very much – Arkadi w Jul 12 '15 at 18:22
  • @Arkadiw - http://stackoverflow.com/questions/18306362/run-r-script-from-command-line – SomethingDark Jul 12 '15 at 18:44