How do i tell windows to open C:\test\test.txt in WordPad, when Notepad is my default program for .txt files?
The accepted answer didn't work for me. I am not sure if it was because of the program I was trying to run, or because the path had spaces in (even though I wrapped it in quotes), or something else.
Anyway, I was able to do it be adding an empty string after the start command.
For example:
start "" "C:\My Programs\myprogram.exe" "C:\My Files\myfile.txt"
You can add the direct path to the executable like
start C:\Windows\System32\write.exe [FILE]
Try:
start wordpad c:\test\test.txt
There is no need to use start when using write.exe, so simply:
write [FILE(S)]
write.exe is located in C:\Windows\System32.
Related
Let's say I have a program that I want to open. I can open it using batch by running this:
#echo off
start "" "C:\Program.exe"
Is there a way to tell batch that I want to open the file using a program such as notepad? Something along the lines of this:
start "" "C:\Program.exe" >notepad.exe
Not sure, but you can use
#echo off
notepad.exe "C:\Program.exe"
You can use every program that supports "Open With" (every good program supports it)
The File-Path will be passed to the program, so it knows your file.
I used following code.
#echo off
start notepad C:\Program.exe
Make sure to set the path to notepad.exe.
You must need double quotes only if you have spaces in the path to your file.
#echo off
start notepad "C:\My Program.exe"
you can use openwith command:
...>openwith "C:program.exe"
this command opens "Open with" window and you can choose witch program "program.exe" should be opened or run with.
you can read more here in Microsoft docs about this command.
I'm trying to create a .cfg file for bcc32 compiler and I'm following the instructions. I have installed correctly and placed an environment path as instructed but when I type "edit bcc32.cfg" into the command prompt it says that edit isn't a valid command? What am I supposed to do?
You could also create a .bat file, edit.bat, to replace the 16-bit edit program (removed because x64 windows flavors won't run it) which would launch your favorite editor.
#echo off
notepad %1
#echo on
This is what I wound up doing as a simple patch so I could carry on the way I always had for the most part. Just type:
edit myfile.ext
in the command prompt to use it.
Note: notepad is not my favorite editor - this is just an example that will work with stock windows.
Note 2: #echo off and #echo on are shown for clarity. You may also shorten this by omitting the echo statements and simply placing the # before the command to be silenced.
#notepad %1
I just use notepad (since they took out the edit command) from the command window like so:
C:\Borland\BCC55\bin> notepad bcc32.cfg
The file will open in notepad for editing. When you've finished editing the file, save it and you're done.
I have found this works for seeing in-window text of a complete file, on a 64bit machine. Once your path is set in cmd prompt, type the word type... followed by "filename" do you see how I used the quotes around the filename only!
type "filename"
You type it just like this (changing filename for your files name) and you will be able to see the entire file text in the cmd window. Not sure how to edit from here on but maybe someone can figure it out from here and tell me.
Assuming you're using Windows 7 (where edit.exe and edlin.exe have been removed):
Use powershell.exe instead of cmd - thereby edit will be available via command line.
Take a look at: http://en.wikipedia.org/wiki/Windows_PowerShell
simple answer....
if your using an old version of windows (xp e.t.c...) you would be able to use edit
but since your using new version of windows, Microsoft has updated and removed the commands that they think are not relevant e.g.. (msg, edit) depending if its a bit32 bit64 or bit82...
Help please..
I wanted to Open the copied file folder once the file has been copied.
I used DOS command start. It works fine as long as the directory path does not contain any space characters.
If I use quotes in the path it rather opne another dos screen:
**Here sample CMD file:
XCopy C:\1\Source\Test.txt C:\1\Target 1\ /R/Y/K
start "C:\1\Target 1\"
Pause**
You had the right idea with the quotes. The tricky bit is that start assumes the first parameter is the window title if it is quoted. If you want to quote your target then you must provide a quoted title first. It can be empty:
start "" "C:\1\Target 1\"
However, if you happen to have a batch file named Target 1.bat, then it will execute the batch script instead of opening the Target 1 folder in Windows Explorer. For that reason, it is safer to use robert oh's answer, explicitly specifying explorer as the target with the folder as a parameter.
You could use
start explorer "c:\some folder\"
On windows, I'm trying to acquire the file name using the %~f1 parameter.
I'm doing this from a new voice (command) which I've added to the contextual menu.
In the windows registry, the voice simply calls a batch script which prints the file name,
by this way:
`C:\script.bat %~f1`
but I get this output:
`C:\Documents and Settings\Administrator\Desktop\%~f1`
so, the path is ok, but what about the filename?!
Suggestions? Thanks!
When the context menu item it triggered, it is done so by Explorer (not cmd.exe) and Explorer does not implement %~f1. Hence you get the current result.
What you need is to modify your script so it receives the whole filename (you would probably put only 'C:\script.bat %1' or 'C:\script.bat' in the registry) and update your script to use %~f1:
#echo first argument: %1
#echo filename only: %~f1
#notepad %~f1
Good luck with that!
Try enclosing the entire variable in %'s.
C:\script.bat %~f1%
I need to create a batch file which starts multiple console applications in a Windows .cmd file. This can be done using the start command.
However, the command has a path in it. I also need to pass paramaters which have spaces as well. How to do this?
E.g. batch file
start "c:\path with spaces\app.exe" param1 "param with spaces"
Actually, his example won't work (although at first I thought that it would, too). Based on the help for the Start command, the first parameter is the name of the newly created Command Prompt window, and the second and third should be the path to the application and its parameters, respectively. If you add another "" before path to the app, it should work (at least it did for me). Use something like this:
start "" "c:\path with spaces\app.exe" param1 "param with spaces"
You can change the first argument to be whatever you want the title of the new command prompt to be. If it's a Windows app that is created, then the command prompt won't be displayed, and the title won't matter.
Escaping the path with apostrophes is correct, but the start command takes a parameter containing the title of the new window. This parameter is detected by the surrounding apostrophes, so your application is not executed.
Try something like this:
start "Dummy Title" "c:\path with spaces\app.exe" param1 "param with spaces"
start "" "c:\path with spaces\app.exe" "C:\path parameter\param.exe"
When I used above suggestion, I've got:
'c:\path' is not recognized a an internal or external command, operable program or batch file.
I think second qoutation mark prevent command to run. After some search below solution save my day:
start "" CALL "c:\path with spaces\app.exe" "C:\path parameter\param.exe"
Interestingly, it seems that in Windows Embedded Compact 7, you cannot specify a title string. The first parameter has to be the command or program.
You are to use something like this:
start /d C:\Windows\System32\calc.exe
start /d "C:\Program Files\Mozilla
Firefox" firefox.exe start /d
"C:\Program Files\Microsoft
Office\Office12" EXCEL.EXE
Also I advice you to use special batch files editor - Dr.Batcher
Surrounding the path and the argument with spaces inside quotes as in your example should do. The command may need to handle the quotes when the parameters are passed to it, but it usually is not a big deal.
I researched successfully and it is working fine for me. My requirement is to sent an email using vbscript which needs to be call from a batch file in windows. Here is the exact command I am using with no errors.
START C:\Windows\System32\cscript.exe "C:\Documents and Settings\akapoor\Desktop\Mail.vbs"