Skip to content
⌘ NSIS Forum Archive

Default file opening method

2 posts

RSS1102#

Default file opening method


I want to register a. md file with the default opening method for my own program, but I tried but was unsuccessful.

Section
  ; 获取安装路径
  StrCpy $0 $INSTDIR\Cherry Noted.exe
  StrCpy $1 $INSTDIR\favicon.ico
  ; 设置 .md 文件的默认打开方式
  WriteRegStr HKCR .md "" "MarkdownFile"
  WriteRegStr HKCR MarkdownFile "" "Cherry Noted file (.md)"
  WriteRegStr HKCR MarkdownFile\DefaultIcon "" "$1"
  WriteRegStr HKCR MarkdownFile\shell\open\command "" '$0 "%1"'
SectionEnd​ 
Anders#
  • You need to be administrator to write to HKCR
  • You will not become the default if some other app already handles .md files, you would have to change the default in the settings app.
  • WriteRegStr HKCR MarkdownFile\shell\open\command "" '"$0" "%1"'