Add "-z" command line option to ignore next parameter


#1

I have Atom configured as my Notepad replacement, using the debugger trick:

$key = "HKLM:/SOFTWARE/Wow6432Node/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/notepad.exe"
md $key -ea SilentlyContinue
set-itemproperty -path $key -name "Debugger" -value "c:\Users\moswald\AppData\Local\atom\bin\atom.cmd -z"

Now whenever something tries to run notepad some_file, the command ....\atom.cmd -z notepad some_file is executed instead. However, Atom tries to open notepad.exe as a file. Several Notepad replacements (Sublime Text, Notepad2, Notepad++, etc…) support the -z option which means “ignore the very next parameter”.

Note this used to work when Atom was installed through Chocolatey because I could set the debugger to “atom.exe” and for whatever reason, this worked fine. Now, the proper way to run Atom is with “atom.cmd”, and it fails.


#2

Couldn’t you just write a wrapper that strips off the first parameter and then calls atom.cmd with the remaining parameters? Why should every application that could possibly be used as a Windows notepad.exe replacement add a special parameter?


#3

Absolutely I could. I could also go in and add it myself and submit a pull request. This is the features board though, so I thought I’d mention that there’s a common feature in several other Windows editors that I miss.


#4

I’m not saying it shouldn’t be added. I can see how it is useful. And this is definitely the place to discuss features for Atom, which is all I was trying to do … discuss it. I was only suggesting a different way of implementing it.


#5

Sorry. I took offense at a perceived tone in your second sentence. I blame the internet.

For anyone interested, this is the powershell script I use to automatically launch Atom instead of Notepad:

$start = 0

if ($args.Length -gt 0)
{
    if ((Split-Path $args[0] -leaf) -eq "notepad.exe")
    {
        $start = 1
    }
}

if ($start -eq $args.Length)
{
    atom
}
else
{
    atom $args[$start..($args.Length - $start)]
}

Enable it with:

$key = "HKLM:/SOFTWARE/Wow6432Node/Microsoft/Windows NT/CurrentVersion/Image File Execution Options/notepad.exe"
md $key -ea SilentlyContinue
set-itemproperty -path $key -name "Debugger" -value "powershell -noprofile -noninteractive -windowstyle hidden -file /path/to/file/launch-atom.ps1"