HKEY_CLASSES_ROOT as variables holder with ASSOC and FTYPE ?

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

HKEY_CLASSES_ROOT as variables holder with ASSOC and FTYPE ?

Post by MigrationUser »

15 Oct 2013 10:30
npocmaka

Probably it's a bad idea but at least is curious (for me)...

The main advantage is that the cmd reloads the HKEY_CLASSES_ROOT every time when ASSOC or FTYPE is called and you can read the registry keys with these command immoderately even if they were set by sub-process commands:
(I've played more with ASSOC)

Code: Select all

C:\Windows\system32>cmd /c assoc *var*=value
*var*=value

C:\Windows\system32>assoc *var*
*var*=value
(this can be used in utilities which starts cmd as sub process to execute some commands as FORFILES,FTP,SCHTASTS .... or different scripts )

Accessing them is far more easier than REG (which also is not included in all Windows versions ) and significantly faster (probably because does not go deep in the registry)

ASSOC is more convenient as FTYPE sometimes checks for existing file extensions before set the value , and sets more additional data (like /shell/open/command and so on..).
Both command are able to set special symbols in `variable` name but there are some weirdnesses :

1.Space or tab is used - sets value when double quotes are used (eg ASSOC ""some thing=something else"") but gives error and the value is not accessible
2.This - ASSOC "a=b" will not set value to extension a as type b but will search for extension of type a=b. Didn't found way to set an quote or back slash in `variable` name.
Quotes are ignored or if there's a quote at the beginning it searches for filetype/extension. Backslash is taken as a path .Equal sign is not processed well when is part of `variable` name.

3.ASSOC command (without parameters) will not list anything that not starts with dot.Neither FTYPE will if its set by ASSOC. Which make ASSOC more ...secure (a kind of) .Also in `variable` name
?<>*/:| are accepted , and as they are forbidden as part of filename , the system could not be harmed much :-) .
4.FTYPE and ASSOC could both write over the same `variable`:

Code: Select all

C:\Windows\system32>assoc :captain:=achab
:captain:=achab

C:\Windows\system32>ftype :captain:=nemo
:captain:=nemo 
which allows a `variable` with two values :-)

Last edited by npocmaka (15 Oct 2013 10:30)

----------------------------

#2 15 Oct 2013 20:00
npocmaka


and something interesting/undocumented :

assoc .=some_filetype will affect all files without extensions.E.g.

Code: Select all

assoc .=txtfile
will make all files without extension text files.
Post Reply