Skip to main content
added 55 characters in body
Source Link

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answera fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open WithOpen With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

replaced http://superuser.com/ with https://superuser.com/
Source Link

I have asked a question, Use an environment variable to point to an "Open With" programUse an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch fileHow to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

added 77 characters in body
Source Link

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1%1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1.

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

I have asked a question, Use an environment variable to point to an "Open With" program, which received a fantastic answer. To add myapp.exe, residing in %MYAPPSDIR%, to the Open With context menu, I should write in the CLI

reg add "HKCR\Applications\myapp.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\myapp\myapp.exe\" \"^%1\"" /f

Now I want to have a .bat file, receiving a parameter, which executes that sentence. E.g., executing regadd.bat myapp.exe would do it. What should the line in the .bat file be?

The points are:

  1. How to include the parameter,
  2. How to include the parameter with .exe removed (for the directory part),
  3. How to avoid expanding %1 that goes into the registry (I do not know how to escape it appropriately).

I found many resources (e.g., How to use `%` in a batch file), but I wouldn't like to tinker with the registry. My bet for 1 and 3 is (still have to work out 2):

reg add "HKCR\Applications\%1\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\(%1 with .exe removed)\%1\" \"^%1\"" /f

I could also set the .bat to be run as regadd.bat myapp. In that case, the line would be

reg add "HKCR\Applications\%1.exe\shell\open\command" /ve /t REG_EXPAND_SZ /d "\"^%MYAPPSDIR^%\%1\%1.exe\" \"^%1\"" /f

I am interested in both options.

added 10 characters in body
Source Link
Dave
  • 25.4k
  • 11
  • 59
  • 70
Loading
added 255 characters in body
Source Link
Loading
Source Link
Loading