Skip to content

Instantly share code, notes, and snippets.

@charlesroper
Forked from jcppkkk/OpenWithSublime.bat
Last active August 29, 2015 14:05
Show Gist options
  • Save charlesroper/0c12fea49059b5592871 to your computer and use it in GitHub Desktop.
Save charlesroper/0c12fea49059b5592871 to your computer and use it in GitHub Desktop.

Revisions

  1. charlesroper revised this gist Aug 17, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions OpenWithSublimeTextAsAdmin.bat
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,8 @@ SET entryName=Sublime Text
    SET menuText=Open with Sublime Text
    SET entryNameAsAdmin=Sublime Text As Admin
    SET menuTextAsAdmin=Open with Sublime Text As Admin
    SET elevate.CmdPath=%~dp0__elevate.cmd
    SET elevate.VbsPath=%~dp0__elevate.vbs
    SET elevateCmdPath=%~dp0__elevate.cmd
    SET elevateVbsPath=%~dp0__elevate.vbs

    echo # Administrative permissions required. Detecting permissions...
    call :check_Permissions
    @@ -31,13 +31,13 @@ reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Ico
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "\"%stPath%\" \"%%1\"" /f

    echo # Download elevate scripts
    call :download "https://gist.github.com/jcppkkk/8330314/raw/3d863b0d5de7b47cb177f0571ffa232d27a3869e/__elevate.cmd" "%elevate.CmdPath%"
    call :download "https://gist.github.com/jcppkkk/8330314/raw/2b89b316d6af469db513a02d156c9a315d684fd0/__elevate.vbs" "%elevate.VbsPath%"
    call :download "https://gist.github.com/jcppkkk/8330314/raw/3d863b0d5de7b47cb177f0571ffa232d27a3869e/__elevate.cmd" "%elevateCmdPath%"
    call :download "https://gist.github.com/jcppkkk/8330314/raw/2b89b316d6af469db513a02d156c9a315d684fd0/__elevate.vbs" "%elevateVbsPath%"

    echo # add it for all file types as admin
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_SZ /v "" /d "%menuTextAsAdmin%" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_EXPAND_SZ /v "Icon" /d "\"%stPath%\",0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "\"%elevate.CmdPath%\" \"%stPath%\" \"%%1\"" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "\"%elevateCmdPath%\" \"%stPath%\" \"%%1\"" /f

    echo # add it for folders
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
  2. @jcppkkk jcppkkk revised this gist Apr 30, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions OpenWithSublimeTextAsAdmin.bat
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@
    @rem Description:
    @rem Install context menu to allow user opens file with Sublime Text as User or Admin, or Open Folder with Sublime Text.
    @rem Usage:
    @rem Download zip and execute all to in Sublime Text's installation folder.
    @rem Execute this script.
    @rem Download this .bat file to in Sublime Text's installation folder.
    @rem Execute this batch file. It will download elevate codes and setup context menu.
    @rem ==================
    @rem \"%stPath%\" : Path to Sublime Text installation dir.
    @rem %entryName%: Key name for the registry entry.
  3. @jcppkkk jcppkkk revised this gist Apr 30, 2014. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions OpenWithSublimeTextAsAdmin.bat
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,13 @@
    @echo off
    @rem ==================
    @rem Source:
    @rem https://gist.github.com/jcppkkk/8330314
    @rem Description:
    @rem Install context menu to allow user opens file with Sublime Text as User or Admin, or Open Folder with Sublime Text.
    @rem Usage:
    @rem Download zip and execute all to in Sublime Text's installation folder.
    @rem Execute this script.
    @rem ==================
    @rem \"%stPath%\" : Path to Sublime Text installation dir.
    @rem %entryName%: Key name for the registry entry.
    @rem %menuText% : Context menu text. Set your preferred menu text (e.g.: translate to your language).
  4. @jcppkkk jcppkkk renamed this gist Jan 9, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @jcppkkk jcppkkk renamed this gist Jan 9, 2014. 1 changed file with 25 additions and 15 deletions.
    40 changes: 25 additions & 15 deletions __OpenWithSublimeText.bat → OpenWithSublimeText.bat
    Original file line number Diff line number Diff line change
    @@ -1,41 +1,44 @@
    @echo off
    @rem %stPath% : Path to Sublime Text installation dir.
    @rem %elevatePath% : Path to elevated privilege script installation dir.
    @rem \"%stPath%\" : Path to Sublime Text installation dir.
    @rem %entryName%: Key name for the registry entry.
    @rem %menuText% : Context menu text. Set your preferred menu text (e.g.: translate to your language).
    @rem %entryNameAsAdmin%: Key name for the registry entry.
    @rem %menuTextAsAdmin% : Context menu text. Set your preferred menu text for administrator privilege (e.g.: translate to your language).

    call :check_Permissions

    SET stPath=\"%~dp0sublime_text.exe\"
    SET elevatePath=\"%~dp0__elevate.cmd\"
    SET stPath=%~dp0sublime_text.exe
    SET entryName=Sublime Text
    SET menuText=Open with Sublime Text
    SET entryNameAsAdmin=Sublime Text As Admin
    SET menuTextAsAdmin=Open with Sublime Text As Admin
    SET elevate.CmdPath=%~dp0__elevate.cmd
    SET elevate.VbsPath=%~dp0__elevate.vbs

    echo # Administrative permissions required. Detecting permissions...
    call :check_Permissions

    echo # add it for all file types
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "\"%stPath%\",0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "\"%stPath%\" \"%%1\"" /f

    echo # Download elevate scripts
    call :download "https://gist.github.com/jcppkkk/8330314/raw/3d863b0d5de7b47cb177f0571ffa232d27a3869e/__elevate.cmd" "%elevate.CmdPath%"
    call :download "https://gist.github.com/jcppkkk/8330314/raw/2b89b316d6af469db513a02d156c9a315d684fd0/__elevate.vbs" "%elevate.VbsPath%"

    echo # add it for all file types as admin
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_SZ /v "" /d "%menuTextAsAdmin%" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "%elevatePath% %stPath% \"%%1\"" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_EXPAND_SZ /v "Icon" /d "\"%stPath%\",0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "\"%elevate.CmdPath%\" \"%stPath%\" \"%%1\"" /f

    echo # add it for folders
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "\"%stPath%\",0" /f
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%\command" /t REG_SZ /v "" /d "\"%stPath%\" \"%%1\"" /f
    pause
    goto :EOF


    :check_Permissions
    echo # Administrative permissions required. Detecting permissions...

    net session >nul 2>&1
    if %errorLevel% == 0 (
    echo Administrative permissions confirmed.
    @@ -45,4 +48,11 @@ if %errorLevel% == 0 (
    echo You will need to "Run as Administrator" if using Vista/Win7/Win8.
    pause >nul
    exit
    )
    )
    goto :EOF


    :download
    @"C:\Windows\System32\WindowsPowerShell\v1.0\powershell" "$wc = New-Object System.Net.WebClient;$wc.DownloadFile('%1', '%2')"
    @echo %2
    @goto :EOF
  6. @jcppkkk jcppkkk revised this gist Jan 9, 2014. 2 changed files with 3 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions __OpenWithSublimeText.bat
    Original file line number Diff line number Diff line change
    @@ -20,10 +20,10 @@ reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_SZ /v "" /d "%men
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f

    echo # add it for all file types as admin. You need to close all sublime instance inorder to open target with Administrative permission.
    echo # add it for all file types as admin
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_SZ /v "" /d "%menuTextAsAdmin%" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "%elevatePath% %stPath% -n \"%%1\"" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "%elevatePath% %stPath% \"%%1\"" /f

    echo # add it for folders
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    1 change: 1 addition & 0 deletions __elevate.cmd
    Original file line number Diff line number Diff line change
    @@ -30,4 +30,5 @@
    set ELEVATE_CMDLINE=%*
    set ELEVATE_APP=%1

    taskkill /f /im sublime_text.exe
    start wscript //nologo "%~dpn0.vbs" %*
  7. @jcppkkk jcppkkk revised this gist Jan 9, 2014. 2 changed files with 40 additions and 11 deletions.
    49 changes: 39 additions & 10 deletions __OpenWithSublimeText.bat
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,48 @@
    @echo off
    @rem %stPath% : Path to Sublime Text installation dir.
    @rem %elevatePath% : Path to elevated privilege script installation dir.
    @rem %entryName%: Key name for the registry entry.
    @rem %menuText% : Context menu text. Set your preferred menu text (e.g.: translate to your language).
    @rem %entryNameAsAdmin%: Key name for the registry entry.
    @rem %menuTextAsAdmin% : Context menu text. Set your preferred menu text for administrator privilege (e.g.: translate to your language).

    SET stPath=C:\Program Files\Sublime Text 3\sublime_text.exe
    call :check_Permissions

    SET stPath=\"%~dp0sublime_text.exe\"
    SET elevatePath=\"%~dp0__elevate.cmd\"
    SET entryName=Sublime Text
    SET menuText=Open with Sublime Text
    SET entryNameAsAdmin=Sublime Text As Admin
    SET menuTextAsAdmin=Open with Sublime Text As Admin

    echo # add it for all file types
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f

    echo # add it for all file types as admin. You need to close all sublime instance inorder to open target with Administrative permission.
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_SZ /v "" /d "%menuTextAsAdmin%" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\*\shell\%entryNameAsAdmin%\command" /t REG_SZ /v "" /d "%elevatePath% %stPath% -n \"%%1\"" /f

    echo # add it for folders
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f
    pause
    goto :EOF


    rem add it for all file types
    @reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f
    :check_Permissions
    echo # Administrative permissions required. Detecting permissions...

    rem add it for folders
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f
    pause
    net session >nul 2>&1
    if %errorLevel% == 0 (
    echo Administrative permissions confirmed.
    goto :EOF
    ) else (
    echo Failure: Current permissions inadequate.
    echo You will need to "Run as Administrator" if using Vista/Win7/Win8.
    pause >nul
    exit
    )
    2 changes: 1 addition & 1 deletion __elevate.vbs
    Original file line number Diff line number Diff line change
    @@ -80,7 +80,7 @@ Sub DisplayUsage
    "" & vbCrLf & _
    "Sample usage with scripts:" & vbCrLf & _
    "" & vbCrLf & _
    " elevate wscript ""C:\windows\system32\slmgr.vbs"" dli" & vbCrLf & _
    " elevate wscript ""C:\windows\system32\slmgr.vbs"" -dli" & vbCrLf & _
    "" & vbCrLf & _
    " elevate powershell -NoExit -Command & 'C:\Temp\Test.ps1'" & vbCrLf & _
    "" & vbCrLf & _
  8. @jcppkkk jcppkkk revised this gist Jan 9, 2014. 3 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
  9. @jcppkkk jcppkkk revised this gist Jan 9, 2014. 2 changed files with 126 additions and 0 deletions.
    33 changes: 33 additions & 0 deletions elevate.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    :: //***************************************************************************
    :: // ***** Script Header *****
    :: // =======================================================
    :: // Elevation PowerToys for Windows Vista v1.1 (04/29/2008)
    :: // =======================================================
    :: //
    :: // File: Elevate.cmd
    :: //
    :: // Additional files required: Elevate.vbs
    :: //
    :: // Purpose: To provide a command line method of launching applications that
    :: // prompt for elevation (Run as Administrator) on Windows Vista.
    :: //
    :: // Usage: elevate.cmd application <application arguments>
    :: //
    :: // Version: 1.0.0
    :: // Date : 01/02/2007
    :: //
    :: // History:
    :: // 1.0.0 01/02/2007 Created initial version.
    :: //
    :: // ***** End Header *****
    :: //***************************************************************************

    @setlocal
    @echo off

    :: Pass raw command line agruments and first argument to Elevate.vbs
    :: through environment variables.
    set ELEVATE_CMDLINE=%*
    set ELEVATE_APP=%1

    start wscript //nologo "%~dpn0.vbs" %*
    93 changes: 93 additions & 0 deletions elevate.vbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,93 @@
    ' //***************************************************************************
    ' // ***** Script Header *****
    ' // =======================================================
    ' // Elevation PowerToys for Windows Vista v1.1 (04/29/2008)
    ' // =======================================================
    ' //
    ' // File: Elevate.vbs
    ' //
    ' // Additional files required: Elevate.cmd
    ' //
    ' // Purpose: To provide a command line method of launching applications that
    ' // prompt for elevation (Run as Administrator) on Windows Vista.
    ' //
    ' // Usage: (Not used directly. Launched from Elevate.cmd.)
    ' //
    ' // Version: 1.0.1
    ' // Date : 01/03/2007
    ' //
    ' // History:
    ' // 1.0.0 01/02/2007 Created initial version.
    ' // 1.0.1 01/03/2007 Added detailed usage output.
    ' //
    ' // ***** End Header *****
    ' //***************************************************************************


    Set objShell = CreateObject("Shell.Application")
    Set objWshShell = WScript.CreateObject("WScript.Shell")
    Set objWshProcessEnv = objWshShell.Environment("PROCESS")

    ' Get raw command line agruments and first argument from Elevate.cmd passed
    ' in through environment variables.
    strCommandLine = objWshProcessEnv("ELEVATE_CMDLINE")
    strApplication = objWshProcessEnv("ELEVATE_APP")
    strArguments = Right(strCommandLine, (Len(strCommandLine) - Len(strApplication)))

    If (WScript.Arguments.Count >= 1) Then
    strFlag = WScript.Arguments(0)
    If (strFlag = "") OR (strFlag="help") OR (strFlag="/h") OR (strFlag="\h") OR (strFlag="-h") _
    OR (strFlag = "\?") OR (strFlag = "/?") OR (strFlag = "-?") OR (strFlag="h") _
    OR (strFlag = "?") Then
    DisplayUsage
    WScript.Quit
    Else
    objShell.ShellExecute strApplication, strArguments, "", "runas"
    End If
    Else
    DisplayUsage
    WScript.Quit
    End If


    Sub DisplayUsage

    WScript.Echo "Elevate - Elevation Command Line Tool for Windows Vista" & vbCrLf & _
    "" & vbCrLf & _
    "Purpose:" & vbCrLf & _
    "--------" & vbCrLf & _
    "To launch applications that prompt for elevation (i.e. Run as Administrator)" & vbCrLf & _
    "from the command line, a script, or the Run box." & vbCrLf & _
    "" & vbCrLf & _
    "Usage: " & vbCrLf & _
    "" & vbCrLf & _
    " elevate application <arguments>" & vbCrLf & _
    "" & vbCrLf & _
    "" & vbCrLf & _
    "Sample usage:" & vbCrLf & _
    "" & vbCrLf & _
    " elevate notepad ""C:\Windows\win.ini""" & vbCrLf & _
    "" & vbCrLf & _
    " elevate cmd /k cd ""C:\Program Files""" & vbCrLf & _
    "" & vbCrLf & _
    " elevate powershell -NoExit -Command Set-Location 'C:\Windows'" & vbCrLf & _
    "" & vbCrLf & _
    "" & vbCrLf & _
    "Usage with scripts: When using the elevate command with scripts such as" & vbCrLf & _
    "Windows Script Host or Windows PowerShell scripts, you should specify" & vbCrLf & _
    "the script host executable (i.e., wscript, cscript, powershell) as the " & vbCrLf & _
    "application." & vbCrLf & _
    "" & vbCrLf & _
    "Sample usage with scripts:" & vbCrLf & _
    "" & vbCrLf & _
    " elevate wscript ""C:\windows\system32\slmgr.vbs"" �dli" & vbCrLf & _
    "" & vbCrLf & _
    " elevate powershell -NoExit -Command & 'C:\Temp\Test.ps1'" & vbCrLf & _
    "" & vbCrLf & _
    "" & vbCrLf & _
    "The elevate command consists of the following files:" & vbCrLf & _
    "" & vbCrLf & _
    " elevate.cmd" & vbCrLf & _
    " elevate.vbs" & vbCrLf

    End Sub
  10. @FoxColdMetal FoxColdMetal revised this gist Nov 10, 2013. 2 changed files with 19 additions and 13 deletions.
    19 changes: 19 additions & 0 deletions OpenWithSublimeText.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    @echo off
    @rem %stPath% : Path to Sublime Text installation dir.
    @rem %entryName%: Key name for the registry entry.
    @rem %menuText% : Context menu text. Set your preferred menu text (e.g.: translate to your language).

    SET stPath=C:\Program Files\Sublime Text 3\sublime_text.exe
    SET entryName=Sublime Text
    SET menuText=Open with Sublime Text

    rem add it for all file types
    @reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f

    rem add it for folders
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_SZ /v "" /d "%menuText%" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\%entryName%\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f
    pause
    13 changes: 0 additions & 13 deletions OpenWithSublimeText2.bat
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    @echo off
    SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe

    rem add it for all file types
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f

    rem add it for folders
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
    pause
  11. @mrchief mrchief revised this gist May 22, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions OpenWithSublimeText2.bat
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,11 @@ SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe

    rem add it for all file types
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f

    rem add it for folders
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
    pause
  12. @mrchief mrchief created this gist May 22, 2013.
    13 changes: 13 additions & 0 deletions OpenWithSublimeText2.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    @echo off
    SET st2Path=C:\Program Files\Sublime Text 2\sublime_text.exe

    rem add it for all file types
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f

    rem add it for folders
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_SZ /v "" /d "Open with Sublime Text 2" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f
    @reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 2\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f
    pause