2

I have a small problem which is I can't change the default value of files with extension .c to open with sublime text editor as default, although I can do that manually, I want to do it via .reg file, so I can do that with other extensions as well with only one reg file.

my tries:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.c\Shell\Open\Command]
"Default"="C:\Program Files\Sublime Text 3\sublime_text.exe"

this creates another Default variable instead of replacing the default variable, I tried this too

[HKEY_CLASSES_ROOT\.c\Shell\Open\Command]
"(Default)"="C:\Program Files\Sublime Text 3\sublime_text.exe"

I thought maybe I need to write it the way it is in registry (Default), but that didn't work too, any solution to my problem?

2
  • 1
    Try using @= instead of "Default"= or "(Default)"=. You may also need to escape the backslashes like this: C:\\Program Files\\Sublime Text 3\\...
    – Sam Forbis
    Commented Apr 22, 2020 at 14:16
  • @SamForbis Thank you for your help
    – Monio1996
    Commented Apr 22, 2020 at 14:23

1 Answer 1

3

Well you have three mistakes, the first one is that you need to escape backslashes, the second is that you need to add the path symbol %1 so that sublime editor gets the path of the file as argument, the third one is you need to write @ if you want to change the default variable inside a key, so you can do that like this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.c\Shell\Open\Command]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe %1"

you can do that using cmd, but you need to open cmd as an Administrator to have access to registry

REG ADD "HKEY_CLASSES_ROOT\.c\Shell\Open\Command" /ve /d "C:\Program Files\Sublime Text 3\sublime_text.exe %1" /f

note: don't escape backslashes in your command, because they are ordinary characters in this case /ve to target Default variable, /d for data, and /f for forcing the overwriting

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .