Force files to open with UE3 or Notepad

Force files to open with UE3 or Notepad

1
NewbieNewbie
1

    Apr 29, 2008#1

    I have UltraEdit on my U3 device. Is it possible to set text files to open with UE when the drive is plugged in? AND open with Notepad when the drive is not plugged in?

    I guess some kind of "if" statement or something.

    Thanks
    Bryan

    6,675585
    Grand MasterGrand Master
    6,675585

      May 01, 2008#2

      It looks like you don't know the mechanism how files are opened when you double click it or enter it on command line and hit key Return.

      The shell of Windows (= Windows Explorer) searches in the registry at HKEY_CLASSES_ROOT (short HKCR) if the extension of this file is registered here. For example HKCR\.txt for files with extension TXT.

      If this is the case the default string value of this registry key is read. For example HKCR\.txt contains as default string value "txtfile".

      Next the key with that value is searched for in HKEY_CLASSES_ROOT and if found, it looks on the default value of subkey shell\open\command. Registry key HKCR\txtfile\shell\open\command for example contains by default the default string value C:\Windows\Notepad.exe %1

      So Windows Explorer starts C:\Windows\Notepad.exe with the full file name of the file you double clicked as first parameter. (%1 is a place holder for the first parameter.)

      So you see that your request is not easily to realize. Which program should be used for opening a file is registered and you need admin rights to change that. And the programs are registered with full path which is not good for programs on a stick because the drive letter can easily change.

      You could write 2 registry files or 2 visual basic scripts to quickly change for the most often opened file types which program should be used to open it depending on your U3 stick is plugged in or not. Registry file 1 or script 1 registers the files for being opened with Notepad and registry file 2 or script 2 registers the files for being opened with UltraEdit on the script. You have the import the correct registry file or run the correct script always manually to change the shell open command registration of the common file types.

      Another method would be to write a program which checks if a stick is plugged in (hopefully the drive letter is always the same) and has UE3 on it or not. This program must have the name Notepad.exe and you must replace original Notepad.exe from Microsoft by your program which of course is not very easy because Notepad.exe is a system protected file - see the forum topics about Notepad replacement. If UE3 is available, your "Notepad.exe" starts UE3 and passes all parameters to it which were passed from Windows Explorer to your "Notepad.exe". If UE3 is not available, your "Notepad.exe" starts original Notepad.exe which was before renamed by you to "Notepadw.exe" (for example) and passes all the parameters to it - normally just 1 file name, but could be also a set of file names or other command line parameters like /print ...
      Best regards from an UC/UE/UES for Windows user from Austria