Open file in New UE Window

This forum is user-to-user based and not regularly monitored by IDM.
Please see the note at the top of this page on how to contact IDM.

Re: Open file in New UE Window

Postby Mofi » Tue May 23, 2006 5:43 am

I detected this while testing the new instance start of UE too.

At WinXP (and probable also Win2K/NT4) the command processor cmd.exe is used for executing a batch file. If a Windows 32-bit GUI application is executed within this batch file, the command processor always waits for the termination of this application and so the batch file does not continue after starting the GUI application. To start a 32-bit GUI application within a batch file without waiting for the termination the command start must be used as I have already described. Use start /? in a command prompt window for details about the start command.

That is a totally different default mechanism as at Win9x where the virtual DOS machine (command.com) by default never waits for the exit of the started Windows GUI application and the start command must be used if the execution of the batch file should be halted until the GUI application has terminated.

The command processor cmd.exe does by default not wait for the termination of a 32-bit GUI application if it is executed directly in an command prompt window and not within a batch file. This handling can be changed by disabling the command extensions either by the cmd.exe option /E:OFF for current call only or be setting the registry value of EnableExtensions to 0 in

HKEY_CURRENT_USER\Software\Microsoft\Command Processor
or
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor


deeptinker what you have seen and I too can be easily explained. If UE/UES is already running with "Multiple Instances=0" and you start again the EXE, the new instance checks the INI parameter, then it checks if an instance of itself is already running. If this is true, the second instance sends an event to the first instance that it should itself bring to foreground and then the second instance terminates itself. The command processor sees the termination of this started task and continues.

Exactly the same happens when I start Opera. If no Opera instance is currently running, the batch file does not continue until Opera is closed. But if an Opera instance is already running, it gets the focus, opens the file/link or a blank page in a new tab and then the batch file continues because the second instance of Opera has terminated itself.


So to get my batch file working on WinNT4, Win2K and WinXP without an open DOS window until the second instance of UE is closed, use it with the start command and simply disable the capture option and the "Show DOS Box" option which is really not needed here.


Very interesting for this topic is the MS article Frequently Asked Questions Regarding The Windows 2000 Command Processor.

And also very helpful are Filemon, Regmon and Process Explorer from SysInternals. Especially the Process Explorer can help a lot because you can see which application has started another application. And when clicking with the right mouse button on a running application and choose properties you can even see very interesting things like the whole command line parameters used on start of the selected application.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4062
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Open file in New UE Window

Postby Mofi » Sun Sep 10, 2006 11:59 am

I have a new solution for opening a file in new UE window without changing the setting for Allow Multiple Instances and if you have the INI not in program directory of UltraEdit also without a second INI. This solution is better because you can have 2 instances and both uses the same INI with identical settings.

I have got this idea while solving a multiple instance problem - see the last 2 posts at Multiple instances won't disable

Although this was bad for bjawnie, it could be also used on purpose. You could create a second UltraEdit program directory which have to contain only following files:

dbghelp.dll
SftpDLL.dll
tidylib.dll
ucl.chm
ucl.exe
ucres.dll

uedit32.chm
uedit32.exe
uedit32.reg
uedos32.exe
ueres.dll

The 3 UltraCompare Lite have to be copied only when not working with UltraCompare Professional or never use File - Compare Files from the second instance of UltraEdit.

Second setup an user tool which runs this copy of uedit32.exe with the different program path and the current file. Because it uses the same uedit32.ini if it is not in the main UltraEdit program directory, the file is opened with a new instance of UltraEdit but uses the same INI file. If you create the environment variable UEINIDIR and set it to the correct directory, it will even work with the INI file in the main UltraEdit program directory.

Unfortunately this method to open the current file in a second instance although Allow Multiple Instances is not checked works only for the first file. When running the tool again to open a second file also in the already existing second instance of UltraEdit, it will not work because the second file will be nevertheless opened always in the first instance. So if further files should be opened in the second instance, they must be opened from within the second instance or by drag & drop to the second instance.

What a pity that opening more than 1 file via command line in an already opened second instance of UltraEdit is not working. That would be really cool, because some file extensions could be registered with the alternate uedit32.exe and double clicking on these files would open the files always in the second/alternate instance while all other files are always opened in the first/main instance.

By the way: Just creating a copy of uedit32.exe in the same directory with a different name is not really better. You would need also a second set of uedit32.* configuration files (ini, kbd, mnu, pmu, tbr) in the prefered INI directory because the default name uedit32.* for the configuration file names is exactly the name of the EXE. And an unchecked Allow Multiple Instances in the alternate INI file would cause the same effect as a second uedit32.exe in a different program path: only the first file is opened in the alternate/second instance and all other files are nevertheless opened in the first/main instance.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4062
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Previous

Return to UltraEdit General Discussion