Windows Paths and file associations via cmd ##################################### Just a note to self on viewing PATHs and PATHEXT in windows (and an explanation of each if your not familiar with it). Also a look at how associations of filetypes are done with command line with Windows. All of this inferred from: http://www.techotopia.com/index.php/Simple_Ruby_Examples COMPLETE SIDENOTE: I start my windows commands with > and my linux commands usually with # (unless im showing a script, in which case I omit the # – unless of course there is a comment then I do have the # as that is the bash # comment symbol) PATH & PATHEXT ############### PATH: what folders to look for executables thru PATHEXT: what file extensions win thinks are executable To view:
> echo %PATH%
> echo %PATHEXT%
Or use: eveeditorfree Example:
>echo %PATHEXT% .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
> echo %PATH% C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\OpenVPN\bin;D:\cygwin\bin;D:\0Programs\android-sdk\platform-tools;C:\Program Files (x86)\OpenVPN\bin;C:\Program Files\smartmontools\bin;C:\Program Files (x86)\FreeArc\bin
Setting the path (its best to set it up front) To set .rb as an extension that is executable
> set PATHEXT=.rb;%PATHEXT%
That will change my PATHEXT to this
.rb;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
To set c:\Ruby\bin\ as a folder to look through for running executables (When typing commands in cmd):
> set PATH=c:\Ruby\bin\;%PATH%
That will set it to this:
c:\Ruby\bin\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\OpenVPN\bin;D:\cygwin\bin;D:\0Programs\android-sdk\platform-tools;C:\Program Files (x86)\OpenVPN\bin;C:\Program Files\smartmontools\bin;C:\Program Files (x86)\FreeArc\bin
ASSOC and FTYPE ################ ftype: ftypes (or filetypes) are associated to the commandline of running the app with its associated files. assoc: associate extensions to filetypes (which associates them to the command line) For example using assoc you can associate .txt files to a ftype called notepad.txt (or anything, with or without a dot).
> assoc .txt=notepad.txt
The syntax is: assoc .extension=ftype so in this case .extension is .txt and ftype is notepad.txt Now we can associate notepad.txt (this looks like a filename dont confuse this for a filename this is just an ftype) which is an ftype to running a program notepad.exe
> ftype notepad.txt="c:\programs\notepad.exe" "%1"
That means that any file that has the extension .txt, when clicked upon will run the following program (imagine a file called story.txt that you just double clicked on) c:\programs\notepad.exe story.txt To print all of the systems ftypes
> ftype > ftypes-saved.txt NOTE: ignore the first > as thats just the cmd prompt, the second > is a redirect so that outputs are saved to the file named on the right (file will save to current folder)
To print all of the assoc
> assoc > assoc-saved.txt NOTE: ignore the first > as thats just the cmd prompt, the second > is a redirect so that outputs are saved to the file named on the right (file will save to current folder)
NOTE: assoc and ftypes work together hand in hand
Thank you!