Welcome to WebmasterWorld Guest from 54.146.221.231

Forum Moderators: bill

Message Too Old, No Replies

Associate Files With Icon

     
3:52 am on Sep 10, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts:210
votes: 0


Hi

Dos Anyone how to Associate a Unknown File Type With an Ico And a Program by using a VBScript ?

i know how to do it manually from The folder Options but i would like to know if its possible to do it in a VBS

Thanks
9:10 am on Sept 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


I don't use Visual Basic, etc. so there may be a function built in, however if not (and assuming you want your code to work pre-vista) then I believe you must make changes directly to the registry.

I found the following code snippet...

REGEDIT4

[HKEY_CLASSES_ROOT\.jar]
@="jarfile"

[HKEY_CLASSES_ROOT\jarfile]
@="Executable Jar File"

[HKEY_CLASSES_ROOT\jarfile\shell]

[HKEY_CLASSES_ROOT\jarfile\shell\open]

[HKEY_CLASSES_ROOT\jarfile\shell\open\command]
@="C:\\Program Files\\JavaSoft\\JRE\\1.3.1\\bin\\javaw.exe -jar %1"


If you place this is a .reg file and execute it, necessary registry changes should be made.

Personally, I would use API functions such as RegOpenKeyEx but this may be more complicated.

Kaled.
6:02 pm on Sept 10, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts:210
votes: 0


Hi Kaled

I Am using Win Xp Pro And i only need it to work on that

i Tried to associate a .tga file with this


REGEDIT4

[HKEY_CLASSES_ROOT\.tga]
@="TGAFile"

[HKEY_CLASSES_ROOT\TGAFile]
@="Executable Jar File"

[HKEY_CLASSES_ROOT\TGAFile\shell]

[HKEY_CLASSES_ROOT\TGAFile\shell\open]

[HKEY_CLASSES_ROOT\TGAFile\shell\open\command]
@="C:\\Documents and Settings\\TheKiller\\Desktop\\test.ico -tga %1"

but it did nothing...


Would you please Make some notes on Where to add the file Extension and the Icon etc

Thanks
10:00 pm on Sept 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


Ok, I've looked more closely,

For a .txt file, four lines appear to be needed for minimum functionality.

REGEDIT4

[HKEY_CLASSES_ROOT\.txt]
@="txtfile"

[HKEY_CLASSES_ROOT\txtfile\DefaultIcon]
@="%SystemRoot%\system32\shell32.dll,-152"

[HKEY_CLASSES_ROOT\txtfile\shell\open\command]
@="%SystemRoot%\system32\NOTEPAD.EXE %1"

Normally the icon will be a .exe file, and the index that follows it will be zero or a positive value.
You might want to use %ProgramFiles% to specify the icon and .exe file.

Since I don't use .reg files myself, I can't guarantee this is correct.

Kaled.
11:25 pm on Sept 10, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts:210
votes: 0


hm.......

In the Windows Folder Options You are able of Selecting the Icon of the X FileType The message it will say when you Right Click it for Example "Run X File","Open X File"
and the program you want to open the file With

i need this mostly For .PHP Files to associate it faster Without going into the Folder Options
8:00 pm on Sept 11, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


I'm not sure I understand you, but if you want to add additional verbs (i.e. menu options) simply add extra lines such as...

[HKEY_CLASSES_ROOT\txtfile\shell\print\command]
@="%SystemRoot%\system32\NOTEPAD.EXE /p %1"

You can also add an alias

[HKEY_CLASSES_ROOT\txtfile\shell\print]
@="Print this file"

Kaled.
12:38 pm on Oct 3, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts: 210
votes: 0


Umm.....

i would like a file that has the fallowing Options that you may find in the :
Tools/FileOptions/FileTypes

like :


1. a .ico image that will represend the File
2. Program to open the file
3. a Action/option you see when you right click the file like Open PHP File
12:05 am on Oct 4, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


I believe I covered these points above.
4:48 pm on Oct 7, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts: 210
votes: 0


yes
but i would like you to but them (each lines)in the order you consider right as i know nothing about reg files

could you please set it for a .PHP Extension ?

Thanks in Advance
1:23 pm on Oct 11, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts: 210
votes: 0


i have tried this to register a .HTML File
it wont work........

REGEDIT4

[HKEY_CLASSES_ROOT\.html]
@="HTMLFile"

[HKEY_CLASSES_ROOT\HTMLFile]
@="Executable HTML File"

[HKEY_CLASSES_ROOT\HTMLFile\shell]

[HKEY_CLASSES_ROOT\HTMLFile\shell\open]

[HKEY_CLASSES_ROOT\HTMLFile\shell\open\command]
@="C:\\Program Files\\Notepad++\\notepad++.exe -html %1"

[HKEY_CLASSES_ROOT\HTMLFile\shell\print\command]
@="C:\Extension Ico\HTML.ico /p %1"

[HKEY_CLASSES_ROOT\HTMLFile\shell\print]
@="Open With Notepad++"
3:37 pm on Oct 11, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


Try the following, however, if .htm and .html are already assigned in the registry, making arbitrary changes may break existing functionality. To avoid this, I would suggest working with the registry directly - see [alanphipps.com...] this should allow to to make additions to existing settings rather than break existing settings.

Also, I don't use notepad++ so the /p switch may not work and I am not certain that .ICO files can be used to specify an icon in this way.

Kaled.


REGEDIT4

[HKEY_CLASSES_ROOT\.htm]
@="HTMLFile"

[HKEY_CLASSES_ROOT\.html]
@="HTMLFile"

[HKEY_CLASSES_ROOT\HTMLFile]
@="HTML File"

[HKEY_CLASSES_ROOT\HTMLfile\DefaultIcon]
@="C:\Extension Ico\HTML.ico"

[HKEY_CLASSES_ROOT\HTMLfile\shell\edit]
@="Edit with Notepad++"

[HKEY_CLASSES_ROOT\HTMLFile\shell\edit\command]
@="C:\Program Files\Notepad++\notepad++.exe %1"

[HKEY_CLASSES_ROOT\HTMLFile\shell\print_nppp]
@="Print using Notepad++"

[HKEY_CLASSES_ROOT\HTMLFile\shell\print_nppp\command]
@="C:\Program Files\Notepad++\notepad++.exe /p %1"
6:00 pm on Oct 11, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts: 210
votes: 0


Hello Kaled

i runned the script and restarted PC
it didnt really did much.........
it opens the file in the normal notepad and the icon works

the other settings like Edit with Notepad plus etc dont work
6:27 pm on Oct 11, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member kaled is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 2, 2003
posts:3710
votes: 0


There's no need to restart the computer after making these changes. As for it not working, I suggest you use RegEdit to verify the changes were made correctly and then check filenames and paths.

Kaled.
7:43 am on Jan 27, 2011 (gmt 0)

Full Member

5+ Year Member

joined:Sept 8, 2010
posts:210
votes: 0


Hello after a long time .. lol

yesterday i have became a bit more familiar with the registry coding
i saw that you can export files etc from the registry editor and i think i've got it :D

i will try to make some page with a few forms to generate the files
but i got to look into the header thing to force downloads :-?