Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify exe to launch with command line arguments without creating shortcut

I'm trying to use winapi methods to modify an exe.

I don't know how to do it by hand either so that would be a good start if someone can share that with me then i can try to programatically acheive it.

Basically have this exe: "C:\Program Files (x86)\Mozilla Firefox\firefox.exe". I copied and pasted it to: "C:\Program Files (x86)\Mozilla Firefox\SecondFirefox.exe"

I don't want to make it a shortcut because I get some weird separation issues on the taskbar.

I want to make "SecondFirefox.exe" launch with default command line arguments of -P "Dev" -no-remote, is this possible?

Thanks

like image 508
Noitidart Avatar asked Jan 11 '15 00:01

Noitidart


People also ask

How do I run an exe from command line arguments?

Every executable accepts different arguments and interprets them in different ways. For example, entering C:\abc.exe /W /F on a command line would run a program called abc.exe and pass two command line arguments to it: /W and /F.

How do I add a command line argument to a program?

Right-click on the shortcut and choose Properties. In the target-field add command line parameters after the program file name. For example: %SystemRoot%\system32\notepad.exe C:\test1. txt.

How do I run an exe from a folder?

In the Environment Variables tab, double click the Path variable in the System variables section. Add the path to the folder containing the .exe to the Path by double clicking on the empty line and paste the path. Click ok and exit. Open a new cmd prompt and hit the command from any folder and it should work.


2 Answers

This will not answer your question on how to do it but it should give you a clue about what is going on

Windows use what is called Application ID which is an attribute for windows,processes and shortcuts. Using this ID Windows is able to determine how taskbar buttons are associated with windows and applications and how the system decides whether an application needs two taskbar buttons for its different windows or whether multiple applications need to share a single taskbar button.

But these IDs can be customized by the applications which means that the application still can specify whether two windows share the same icon or not

I create a small executable then I duplicate it and start them together, the result is each one has its own icon.

But this were not the case with firefox when I duplicate the executable

It is likely that firefox is altering the Application IDs of all running instances to one application ID and that is why all firefox taskbar icons are combined. with that being said even if you tried to build it on your own, it is not easy to do.

I don't know for sure because I don't want to read the source code but you can still check out if that is Right.

Check out this link for more information about taskbar API

like image 183
Ameen Avatar answered Oct 04 '22 20:10

Ameen


Making a copy of the executable seems like a poor idea. Why should you have two copies of the same thing.

I'd make a launcher program. A very simple program that did nothing more than launch the original executable using the modified command line.

like image 30
David Heffernan Avatar answered Oct 04 '22 21:10

David Heffernan