How can I start a file with an associated non-default command (shell verb) like "edit", "print", ... from command-line or from a .bat script by using standard Windows means.
(Those extra actions which you get offered on top upon right-click on a file in the Windows Explorer.)
Thus getting the effect of
python -c "import os;os.startfile('somepic.png', 'edit')"
(ShellExecuteEx), but without using extra tools like python, powershell, or so. The START command does not seem to offer that.
Not sure if this is what you are looking for, but using the START command opens the file I want to edit in the default program.
It is possible to do with batch code what is done by command START for default action of opening a file with associated application.
In the commented batch code below the shell verb must be specified in third line being assigned to environment variable
ActionCommand
.The name of the file to
edit
,printto
, ... must be specified as first parameter of the batch file.This batch file might not work for all possible action commands, but it should work for 99.5% of all
edit
,printto
, ... commands.For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /?
echo /?
endlocal /?
for /?
goto /?
if /?
pause /?
reg query /?
rem /?
set /?
setlocal /?
start /?
An example to show how to do it with an one-liner:
It will open the dummy
autoexec.bat
file with the application defined to edit.bat
files (by default, Notepad).As learned from the comments and after further searching: there seems to be no direct command for that task in standard Windows indeed.
However using a VBScript snippet should be highly compatible and have lowest system requirements. (Works on all machines here directly - from XP - unlike JScript)
Example script shellexec.vbs :
Use from command-line or batch-file:
or: