“Forking” a long running command to a new tab with ConEmu. The magic of -new_console:c

Here’s a quick tip I’d thought I’d share after being quite rightly told to RTFM by the author of ConEmu.

Suppose you are running FarManager from ConEmu and want to update all your chocolatey packages. You can do so with the command cup all. However, that will block your FarManager session until the cup all completes. You have four options to fix this:

  1. You can start a new tab in ConEmu with the menu. This is undesirable because you’re obviously a command line guy.
  2. You press Shift+Enter after the cup all command. This is undesirable because unless you configure ConEmu to intercept every new command window, a regular console window will appear. Also, the console will close automatically upon completion.
  3. You can type cup all & pause and hit Shift+Enter to allow the window to stay open. Or
  4. You can type cup all -new_console:c to open a new tab that will execute the command, and not close upon completion.

Obviously I recommend option 4.

MSIExec and Far Manager Part 1: Command line install and uninstall of FarManager 3

This is part one in a series of blog articles in which I shed light on the internals of MSIs using the example of the MSI for Far Manager 3. It was inspired, amongst other thing, by lessons learned while creating the Far-2 and Far-3 packages for chocolatey. While the idea of writing those packages was so others would not have to learn the dark arts of command line manipulation of MSIs, I though I would write this series for those interested in how the sausage gets made.

I’ve written about my love of the File and Archive Manager before. I’m a command line guy so this utility naturally appeals to me. In addition to being a command line guy, I’m also very much a MSI guy. I always prefer installers to unzipping files somewhere, and I prefer MSI installers to exe based installers such as those made with the Nullsoft Scriptable Installer System. On the surface it might seem like these two loves would be in conflict. After all, when you run an MSI you get a GUI. However, there is a command line executable for installing MSIs, called MSIExec.

So using the example of  a recent 64 bit nightly build of Far Manager 3.0, C:userszippyDownloadsFar30b2746.x64.20120624.msi, lets explore how we can install and uninstall an MSI from the command like.

Getting some help with msiexec /?

MSIExec comes with built-in help. To see it, type msiexec /? from the command line.  Strangely, it will display that help in a window instead of the console. This is similar to the behavior of ntbackup.

Let’s install Far Manager!

Looking through the command line install options, /i is the switch to install an MSI. To have no GUI feedback I can use /quiet. If I want just a status bar I can use /passive. So  to install far automatically, I can use the following command:

msiexec /x "C:\users\zippy\Downloads\Far30b2746.x64.20120624.msi" /passive

This will give you a default install of Far Manager 3.0. However, if you use Far, you are by definition a power user, and you probably don’t pick the default install options. It is possible to customize what features to install during a command line install. I’ll explain your options for doing that in part 2.

Time to uninstall it

I can only see one reason to want to uninstall Far Manager 3.0. That would be of course when Far Manager 4.o comes out! Since Far 3.0 is still under development, that event is probably at least 2 years away. However, we want to be prepared for that day. Also, Far is just the example we are using. There are other programs that are installed with an MSI that deserve to be uninstalled.

If you examine the msiexec /? documentation, then you will see that the uninstall syntax is msiexec </uninstall | /x> <Product.msi | ProductCode>. The /uninstall and /x switches are identical, but I prefer /x because its terser. ProductCode is a GUID that I’ll explain how to get later. For now, lets use the path of the original MSI. So in our example the command is.

msiexec /x "C:\users\zippy\Downloads\Far30b2746.x64.20120624.msi" /passive

That’s fairly simple. However, you don’t always have the MSI available for something you want to uninstall.

Finding the Product Code

The ProductCode is a GUID. The method for finding it is not obvious. I’ve resorted to using WMI, but there are probably other methods. Specifically, I use the Win32_Product class. The best way to do this from the command line is  with the PowerShell cmdlet  Get-WmiObject. The command to search for all instances of Far Manager installed via MSI on your system is:

Get-WmiObject Win32_Product -Filter 'Name LIKE "Far Manager %"'

This returns the following on my machine:

IdentifyingNumber : {143F0C11-D9F3-4F1E-9037-67BBFDD379AD}
Name              : Far Manager 2 x64
Vendor            : Eugene Roshal &amp; Far Group
Version           : 2.0.1807
Caption           : Far Manager 2 x64

IdentifyingNumber : {B0911B7C-968A-4448-BAF2-0FF2DA34B805}
Name              : Far Manager 3 x64
Vendor            : Eugene Roshal &amp; Far Group
Version           : 3.0.2779
Caption           : Far Manager 3 x64

As you can see, I have versions 2.0 and 3.0 of Far installed. I could uninstall Far 2.0 with the command msiexec /x {143F0C11-D9F3-4F1E-9037-67BBFDD379AD} /passive. If you want to get fancy and uninstall both at the same time, you can with the help of the Start-Process cmdlet.

Get-WmiObject Win32_Product -Filter 'Name LIKE "Far Manager %"' | %{ start msiexec '/x',$($_.IdentifyingNumber),'/passive'  -Wait }

Special thanks to Trevor Sullivan (blog|twitter), for helping me out on a Sunday with the Start-Process syntax.

I’ve barely scratched the surface of what you can do with the MSIExec. However, its a good start. In Part 2 I’ll discuss how to customize the install.

Some 64 bit Farmanager plugin links

I’ve previously written about my love of FAR, the File and ARchive manager. One of its greatest strengths is all the plugins written for it. However, some of the most popular plugins are no longer maintained (because they just work), and were not ported to 64 bit. Luckily, this is becoming less and less of an issue.

I have therefore compiled this short list of sites with 64-bit FarManager plugins. BTW these days U run nightly builds of Far3. Some of these plugins might not work in Far2.

  • Evil Programmers is a google code project with 64 bit builds of plugins. Most of the downloads only include
  • Andrew Grechkin’s plugins. The only one I’ve actually used is the service manager plugin. This site also has plugins for FarManager 3.
  • NexBox This is a fork of the WinSCP plugin for Far. Unlike the original version, there is a 64-bit build of this.
  • FarPlug Google Code Project This has three plugins currently. The first is the arclight plugin that allows far to manipulate zip, 7z, rar and other archive formats. The second allows you to view the contents of movile device docked with ActiveSync, and the third lets you view information about NTFS file systems.

UPDATES 2012-09-06:

  • Conemu. Scott Hanselman blogged about this replacement to Console2 and converted me instantly. While ConEmu works fine with cmd.exe and powershell.exe. it also includes plugins for FarManager and integrates very nicely. The conemu project also hosts several plugins and a wrapper to run Far2 plugins in Far3.
  • FarPlugs Google Code Project. A similar name to the above project, but a completely different set of plugins. There is an AutoUpdate plugin that will update Far Itself, Conemu, NetBox, and all the plugins on this site. There is a nice PEImage viewer for those that do low level win32 programming. There is also a useful looking SQLite editor.

My new favorite tool, the Far File manager

Strange things excite me, things even other programmers would consider strange to be excited about. Every once in a while, something comes along that excites me in multiple ways. One of those things is the orthodox file manager, Far.

The far manager was developed by Eugene Roshal, who created WinRar. It was originally shareware, but has recently been made open source.

I’ve known about Far for a while. I first discovered it looking for a file manager that could handle a directory with thousands of files at a job where I was doing ETL operations. It was installed on my machine by a developer of ReSharper who was troubleshooting a very strange bug on my system remotely. Also I worked in a company where several Russian’s used it daily.

However, while I toyed with it several times, I never took the time to really get to know it until a few weeks ago. By really getting to know it I meant installing several plugins, and experiencing the “theres a plugin for that” joy several times over.

Overview

Far is a command line based file manager with two columns and a command prompt. The command prompt behaves similar to cmd.exe, but not exactly. For example, in a standard command prompt typing “cd e:foo” whike you are on the c: drive will change the current directory on the E: drive but you still have to type e: to get to that folder. In Far typing cd e:foo does both. One other difference, that bothered my unix sensibilities, is “cd ~” changes to the folder that far is installed to. In unix this changes to the users home directory so I was expecting similar behavior. There are probably many other useful command line enhancements that I’ve yet to discover yet as well.

Far Screenshot
Far File Manager

Installing Far and plugins.

Far is available on http://farmanager.com. There is a 1.7 and 2.0 version. The 2.0 version supports unicode asnd the 1.7 version us the legacy ascii version. You can get 64 bit binaries for both versions. You can install far via an MSI, or a 7-zip archive.

After you install Far, you will want to install several plugins. I will highlight my favorite ones here. ote that while binaries compiled against the far 1.7 SDK will work with Far 2.0, 32 bit plugins will not work with 64 bit far. For this reason you probably want to install the 32 bit version of Far, unless you are like me and like pain.

Except where mentioned, these plugins can either be found at the plugring site, or for 64 bit binaries, the evil programmers google code project. I will go through some of the plugins I like below.

7-Zip

As far as I know, there is no 64 bit version of this available yet. However, I probably just haven’t found it yet. If you install far without this plugin, you can browse the contents of most archives in Far. However, you will not be able to copy files out of them. I’ve yet to try getting the built-in archive support full working. However, with all the archives supported by 7-zip, I’m in no hurry to.

Event Viewer

This works like a text mode only version of eventvwr.exe. I’ve yet to find a truly compelling case to use it over the standar gui version. However, its nice to have an alternative tool for any job.

Service Manager

This is really convenient. It lists drivers and services temperately. It also allows you to edit things you can’t in the mmc snap-in, such as the path to the binary the service executes. Finally, it lets you create a new service. You rarely need to do this, but when you do its hard to find a good tool for the job.

User Manager

This one is really useful, especially on XP Home edition. Functionality is similar to the “Local Users and Groups” section of the Computer Management MMC snap-in on XP Pro. The thing I really love about it is you can set the “User must change password at next logon” flag on a user in XP Home Edition. I spent the good part of a train ride from Penn Station to Islip on Friday failing to achieve this in other ways. I’m not saying its the only way this task can be done. I’m just saying that this plugin will let me accomplish this task easily.

User Must Change Password At Next Logon

WinSCP

The arbitrariness of alphabetical order has put what is perhaps the most useful plugin last. There is a GUI scp/sftp client for windows called WinSCP. The author also made a Far plug-in based on the same code.

This plug-in, along with the 7-zip one, also take advantage of one of the most powerful intrinsic features of Far. With Far, you can copy any file from one panel to another, regardless of whether the panels contain a local folder, a unc path, the inside of an archive, or a sftp folder. Because of this, Far is a great tool for moving files to and from remote servers.

Conclusion

Far is a great file manager, and I will spend more time getting to know it. I think all programmers and sys-admins that work with Windows should get familiar with it as well.