11

Suppose some author has enforced his Windows application to be single instance. Is there any way to make multiple instance of this application (aside from running inside a virtual machine or requesting the author to rewrite the app)?

If there is a readymade tool, I would like to know it. (I have tried sandboxie and Altiris SVS without luck).

If there is nothing out there, I want to program a tool/hack that will let me do this. I am looking for pointers where to start - what will be involved, what skills would be needed. I have moderate programming skills in C and Java.

If this cannot be done, please explain why.

EDIT: I know its a bad idea but I still need to do it (for various reasons). I want a generic way that works for any application and does not introduce errors.

  • 3
    Windows applications are not singletons by default. If they are, it means someone put in the extra effort to make it a singleton and probably has a reason for doing so. – In silico Jul 20 '10 at 18:56
  • 1
    Depends on how the application is checking for multiple copies. Various applications check in different ways and some applications will check in multiple ways. – ho1 Jul 20 '10 at 18:57
  • As In Silico says though, it's probably not a good idea. The app might corrupt data, crash or cause other problems if you've got multiple copies running when they're not meant to. – ho1 Jul 20 '10 at 18:59
  • There are many ways a process can enforce running only a single instance; I don't think it is feasible to build a generic tool capable of preventing this. You would have to examine each application individually and write something tailored specifically for it. – Luke Jul 20 '10 at 19:42
  • Have you found a solution? – Tomas Jun 25 '12 at 10:09
2

Many applications check the global list of processes (with EnumProcesses, OpenProcess, GetModuleBaseName, and similar functions) or list of windows (with EnumWindows, EnumChildWindows).

You may try to set hook (see samples SetWindowsHookEx, CallNextHookEx, etc) to hook those specific API function calls from that application and replace requested data in response with yours to fool the application.

  • Thanks for all the answers. I guess the tool needs some careful design. The envisioned tool should be somewhat like a very lightweight virtual OS environment that does not involve running a full copy of windows, yet fools all applications. – Jus12 Aug 6 '10 at 8:31
4

There is no generic way because different applications use different methods. Many of the methods involve trying to get some machine-wide (or, at least, user-wide) resource (e.g., a named synchronization object, a file with a well-known name and location, or a registry value). If the app succeeds, then it holds that resource as long as it runs. If it fails because another instance already holds the resource, then it might try to signal the original instance so that it can respond.

In 16-bit Windows, when a program started, the OS passed it a unique handle called an HINSTANCE. It would also be passed the HINSTANCE of a currently running process using the same executable (if any). In those days, that was probably the most common way for the program to know if a copy was already running. In 32-bit Windows, with protected memory, process-specific address spaces, and the end of cooperative multitasking, the HINSTANCEs no longer carried the same meaning.

A small number of apps do this simply for "usability", but for many others, there may be a good reason to enforce singletons. Bypassing that could lead to data corruption or simply failing to run.

3

You can run application on different users accounts and instance checking will not work anymore.

2

It is possible!

Here is an image of me running half-life 1 4x in 4 windows all connected to the same LAN server, the only problem is the controllers not being independently linked to each window.

https://web.archive.org/web/20150315150158if_/http://img29.imageshack.us/img29/5642/yc0y.jpg

To do this, you need 'Process Explorer' - a program that allows you to do what is known as 'Close Handle' on the '\BaseNamedObjects\ValveHalfLifeLauncherMutex' sub-process or something. its not that hard. go here for detailed instructions - http://am.half-lifecreations.com/forums/index.php?topic=479.0

But yeah that's for half-life but get Process Explorer and im sure you'll be able to find which handle/process you need to close in order to get the programs u want running multi times.

I dont see why windows doesn't implement running games multi times in splits/snaps as a feature anyway! its clearly because people wouldn't buy as many PC's... also check out SoftXSpand really awesome, allows u to run multiple instances of windows as independent users

  • Close a mutant handle works for me. It's not half-life but using a mutex on the programmer's side is pretty common so this solution is kind of generic. – AZ. Mar 27 '14 at 16:49
1

Lock files, named pipes and synchronisation events are some of the common ways applications use to check they're the only running instance. To work around lock files you'd either have to virtualise the file system, hook into it or do a carefully timed delete (and that may not work if it locks the file open too). Named pipes and synchronisation events will be much more difficult because you don't have the same control from outside the application that you do with files.

0

In Windows 8 and newer, you hold the Shift key and click the programs' icon/button on taskbar. This will launch the executable again. If the app does not self check for clones, you will have a new window.

This will ofcourse potentially create conflicts with the app internal files if it opens for example an internal sqlite file, so you must really know what you are doing or don't care if something breaks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.