SetRegistry Here again with Windows 7

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

SetRegistry Here again with Windows 7

Post by trevix » Tue Oct 02, 2012 6:12 pm

Hi all.

I'm trying to build my own installer but I'm having problems with file association in Windows 7, while it runs fine on Windows XP.
This is the code I'm using, found on various website:

Code: Select all

   put "Tcal into TheAppName	
  put "C:\Program Files\AA_MyApp\Tcal.exe" tAppPath
   put ".tcl" into TheExension

    if queryregistry("HKEY_CLASSES_ROOT\.tcl\") <> "Tcal" then
      get setRegistry("HKEY_CLASSES_ROOT\.tcl\","Tcal")
   end if

   if queryregistry("HKEY_CLASSES_ROOT\Tcal\") <>"Tcal document" then
      get setRegistry("HKEY_CLASSES_ROOT\Tcal\","Tcal document")
   end if

   put tAppPath & ",1" into tVar
   if queryregistry("HKEY_CLASSES_ROOT\Tcal\DefaultIcon\") <> tVar then
      get setRegistry("HKEY_CLASSES_ROOT\Tcal\DefaultIcon\",tVar) 
   end if
 
   put tAppPath & " %1" into tVar
   if queryregistry("HKEY_CLASSES_ROOT\Tcal\shell\open\command\") <> tVar then
      get setRegistry("HKEY_CLASSES_ROOT\Tcal\shell\open\command\",tVar) 
   end if
This is the property of the file
Cattura.PNG
This is the RegEdit listing (seems OK)
Cattura2.PNG
Cattura2.PNG (6.17 KiB) Viewed 3519 times
Still, when I double click on the document ("Paoli.tcl") it does not launch Tcal.exe, and there is no sign of the doc icon.
The app Tcal.exe should be Ok since, if installed with Inno, it works fine and i have the icon.

More...if on Windows I change the default app of the paoli.tcl to "NotePad", when I run the script above it does not revert to Tcal.exe, even if the quesryregistry shows correct keys...
Any clue ? Am I missing something ? Thanks

Trevix

Livecode 5.5.2, Windows 7 professional sp1 running under VMware
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

trevix
Posts: 1064
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: SetRegistry Here again with Windows 7 UPDATE

Post by trevix » Thu Oct 04, 2012 12:21 pm

I need to correct myself, sorry. It worked on Windows XP because there was not previous track of my app or doc of the same.
first af all, given:
The application name: "Tcal"
The application path: tAppPath = "C:\Program Files\AA_MyApp\Tcal.exe"
The Document extension: ".tcl"
"TcalDoc" is a generic choosen name to reference a Tcal doc file.
Let me correct my code:

Code: Select all

 if queryregistry("HKEY_CLASSES_ROOT\.tcl\") <> "TcalDoc" then
      get setRegistry("HKEY_CLASSES_ROOT\.tcl\","TcalDoc")
   end if
   if queryregistry("HKEY_CLASSES_ROOT\TcalDoc\") <>"Tcal document" then
      get setRegistry("HKEY_CLASSES_ROOT\TcalDoc\","Tcal document")
   end if
   put tAppPath & ",1" into tVar
   if queryregistry("HKEY_CLASSES_ROOT\TcalDoc\DefaultIcon\") <> tVar then
      get setRegistry("HKEY_CLASSES_ROOT\TcalDoc\DefaultIcon\",tVar)
   end if
   put tAppPath & " %1" into tVar
   if queryregistry("HKEY_CLASSES_ROOT\TcalDoc\shell\open\command\") <> tVar then
      get setRegistry("HKEY_CLASSES_ROOT\TcalDoc\shell\open\command\",tVar)
   end if
Endeed this code works BUT only if there is NOT a previous "usermade" association (with in Explorer)of ".tcl"

I found that, doing a file association in Windows explorer, there are these finding in RegEdit:
  • HKCR\.tcl > value="tcl_auto_file" (where I guess "tcl_auto_file" = "TcalDoc")
    HKCR\tcl_auto_file\shell\open\command >predefined value= C:\Program Files\AA_MyApp\Tcal.exe %1
    HKCR\Applications\Tcal.exe\shell\open\command >predefined= "C:\Program Files\AA_MyApp\Tcal.exe" "%1"
    HKCU\software\classes\.tcl >predefined value= "tcl_auto_file"
    HKCU\software\classes\Applications\Tcal.exe\shell\open\command > predefined value="C:\Program Files\AA_MyApp\Tcal.exe" "%1"
    HKCU\software\classes\tcl_auto_file\shell\open\command >predefined value= C:\Program Files\AA_MyApp\Tcal.exe %1
    HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tcl\OpenWithList > name=a value="Tcal.exe" and name= MRUList value= a
I did not mention "HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs..." and other incomprensible finding (cache, etc.)

Doing a clean up with regedit and then using the code above, I find:
  • HKCR\.tcl >predefined value= TcalDoc (OK)
    HKCR\TcalDoc\Defaulticon >predefined value= C:\Program Files\AA_MyApp\Tcal.exe,1
    HKCR\TcalDoc\shell\open\command >predefined value= C:\Program Files\AA_MyApp\Tcal.exe %1
    HKCU\software\classes\.tcl >predefined value= TcalDoc
    HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tcl\OpenWithList > name=a value=Tcal.exe and name= MRUList value= a
    HKLM\software\classes\.tcl >predefined value= TcalDoc
    HKLM\software\classes\TcalDoc\DefaultIcon >predefined value= C:\Program Files\AA_MyApp\Tcal.exe,1
    HKLM\software\classes\TcalDoc\shell\open\command >predefined value= C:\Program Files\AA_MyApp\Tcal.exe %1
So my questions are:
1) should I include in the code some more code, like:

HKCR\Applications\Tcal.exe\shell\open\command >predefined= "C:\Program Files\AA_MyApp\Tcal.exe" "%1"
and also (but I believe it does not matter):
HKCU\software\classes\Applications\Tcal.exe\shell\open\command > predefined value="C:\Program Files\AA_MyApp\Tcal.exe" "%1"
HKCU\software\classes\TcalDoc\shell\open\command >predefined value= C:\Program Files\AA_MyApp\Tcal.exe %1

2) is any way to update trough code the desk icons other then restart or doing a new login ?
3) Should I delete, on Uninstall, the exact same registry of the install ?
Thanks for any help on this
Trevix
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply