My Technical Notes

Friday, 23 January 2015

Making Fsi.exe callable on the command line

There are multiple ways of doing this. Below is the method I prefer:

  • First create a folder in which you will store your commandline application shortcuts. I am going to call the folder `pathlinks`.
  • In your `pathlinks` folder, add a bat file called `fsi.bat` and include the following code:
    @"C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\Fsi.exe" %*

    `@` suppresses echoing the command to the invoking shell. The quotations `""` prevent white space being interpreted as argument delimiters. `%*` pastes any arguments to the batch file, to the quoted executable instead.

  • Lastly, we include the `pathlinks` folder on the `PATH` environment variable. We can do this two ways:
    • Open `Regedit.exe` as administrator and add `C:\...\pathlinks` to `PATH` in either of the following "folders":

      If you want to change the current users's path, or
      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
      If you want to change the machine's path.

    • An alternative way, is to execute in an administrator-privileged cmd:
      setx PATH "%PATH%;C:\...\pathlinks"
      You can add the `-m` argument if you want to change the machine's path variable. Otherwise leave it out to change the user's path variable. One issue with this is that it truncates `PATH` to 1024 characters, so the above method might be better.

You can then execute `fsi` on the command line and it will be interpreted to `fsi.bat`.


No comments: