# Create .exe file from shortcut?



## Sidious

Kind of unclear on what you want? More of an explanation of what your doing/situation?


----------



## thiru

You want to make an .exe that executes another .exe?


----------



## Limes

Yes, basically right I have a .exe file which requires parameters such as -parameter1 -parameter2 -parameter3, etc, so I created a shortcut to this exe with the parameters in the target line, I would like to make a single .exe file with these parameters already included.


----------



## _02

Paramters are passed INTO an executable, not contained within it.

The point of a parameter is to pass things at runtime, not compile time. Building an executable with the parameters built in is no different than just hard coding the options.

Edit - I assume you have an EXE that you didn't compile so you can't hard code things. You can write a whole other program to execute that file with parameters, but it would literally achieve the same thing that doing the shortcut method will.

I don't know the code off hand, but it would be an extremely simple program that you could write and compile using even BASIC.

I don't get the point.


----------



## Limes

Quote:


> Originally Posted by *_02;12136841*
> Paramters are passed INTO an executable, not contained within it.
> 
> The point of a parameter is to pass things at runtime, not compile time. Building an executable with the parameters built in is no different than not allowing parameters, and just hard coding the options.
> 
> Why do you need it to accept paramters, AND have the parameters built in?
> 
> Edit - I assume you have an EXE that you didn't compile. You can write a whole other program to execute that file with parameters, but it would literally achieve the same thing that doing the shortcut method will.
> 
> I don't get the point.


Maybe I should explain it better. Alright take this for example for srcds game servers.

There is a single file called hldsupdatetool.exe, now if I create a shortcut to it, add the following to the target line so it looks like so..

"C:\srcds\hldsupdatetool.exe" -command update -game tf -dir .

Everything from the -command to the period at the end is what I would want to build into a single .exe, so the file would launch as an executable, not a shortcut to an executable.

I know its possible as I have had someone do it for me before, however I am not using it for hldsupdatetool, but merely providing that as an example.


----------



## _02

Sure, I get that.

However, that is why there are parameter options built into the shortcuts in windows, that is how they are supposed to be executed. The next way you are supposed to do this would be using a batch file.

If you need it to be in an executable (for what reason I can't imagine) you will just need to write a small program which executes your intended EXE with the proper paramters, and then compile that and put it in the directory of the program you want to execute (or build a way for it to find the EXE into your program).

You can do this in virtually any language, even BASIC (with a compiler capable of producing an EXE). Depending on the language, the commands will be different, but you should only need to look at the language reference for "Executing external programs", etc. to find out the code.

I think in BASIC it is shell or shellexecute.


----------



## anoob

Yeah, I don't get it either. I think the thing here is that why does it need to be an .EXE? Is there a reason why it needs to be .EXE extension? I think this is what is confusing everyone.


----------



## Limes

Quote:


> Originally Posted by *_02;12136951*
> Sure, I get that.
> 
> However, that is why there are parameter options built into the shortcuts in windows, that is how they are supposed to be executed. The next way you are supposed to do this would be using a batch file.
> 
> If you need it to be in an executable (for what reason I can't imagine) you will just need to write a small program which executes your intended EXE with the proper paramters, and then compile that and put it in the directory of the program you want to execute (or build a way for it to find the EXE into your program).
> 
> You can do this in virtually any language, even BASIC (with a compiler capable of producing an EXE). Depending on the language, the commands will be different, but you should only need to look at the language reference for "Executing external programs", etc. to find out the code.
> 
> I think in BASIC it is shell or shellexecute, but I haven't programmed in BASIC since DOS =)


That would be optimal. The .exe will be in the same place as the other one, the only difference between the two would be that the single exe will have all the necessary parameters included, so I don't have to create shortcuts all the time and I just launch it.

However my question still stands whats the best way of doing this? I know very little to no C++.


----------



## Plex

You can't just open a compiled exe file and add parameters to it. You either need to pass them in a DOS shell (batch file) or with a Windows shortcut.


----------



## Plex

Quote:


> Originally Posted by *Limes;12137000*
> That would be optimal. The .exe will be in the same place as the other one, the only difference between the two would be that the single exe will have all the necessary parameters included, so I don't have to create shortcuts all the time and I just launch it.
> 
> However my question still stands whats the best way of doing this? I know very little to no C++.


Making shortcuts all of the time? You only have to make the shortcut once. What is the difference between that and going through all of the trouble to compile an entirely different program to pass parameters for you? That doesn't make any sense.


----------



## Limes

Quote:


> Originally Posted by *Plex;12137007*
> You can't just open a compiled exe file and add parameters to it. You either need to pass them in a DOS shell (batch file) or with a Windows shortcut.


I never said you could. I am asking how to build an .exe with certain parameters already built into it.
Quote:


> Originally Posted by *Plex;12137031*
> Making shortcuts all of the time? You only have to make the shortcut once. What is the difference between that and going through all of the trouble to compile an entirely different program to pass parameters for you? That doesn't make any sense.


Sigh...please stop straying away from the original question, and yes if I am running multiple versions of an application, I have to create a new shortcut and add the parameters again due to the fact its in entirely different directories, why should I do that when I can easily drop the new .exe in the same directory.

Either way my question isn't should I or should I not, its how can I, I would appreciate it if we could keep the discussion to my original post.


----------



## Plex

Quote:


> Originally Posted by *Limes;12137035*
> I never said you could. I am asking how to build an .exe with certain parameters already built into it.


Do you have the source code for the program you're talking about? If not, then you can't.

What is suggested above is that you create an entirely separate program that sits in the same location that just executes the original executable and adds the parameters at runtime. Literally the exact same thing creating a shortcut does.


----------



## _02

Quote:


> Originally Posted by *Limes;12137000*
> However my question still stands whats the best way of doing this? I know very little to no C++.


If you aren't familiar with any programming language capable of producing an executable, you are a long way from your solution (that is already solved by typing less than a line into your shortcut launch options).

I know you have some hidden reason that you want this EXE, so here is the code to achieve that in BASIC (compiled using liberty basic, a free compiler). It is very simple to set up and use, just install, type the code, and compile to exe.

Code:



Code:


run "PROGRAM.EXE -param1 -param2"

That one line will spit out a program that does just what you want. Global and local path applies for the location of the executable. BASIC is likely not the best language to program in, but you can get a free compiler and be done with this project in under 30 seconds.

Edit - Fixed code.


----------



## Wiremaster

1. Write a batch file as others have stated to launch the program.
2. Use this to make it an .exe
3. Run it.

I have done this all the time. It's awesome.


----------



## _02

Quote:


> Originally Posted by *Wiremaster;12137120*
> 1. Write a batch file as others have stated to launch the program.
> 2. Use this to make it an .exe
> 3. Run it.
> 
> I have done this all the time. It's awesome.


Nifty!


----------



## Wiremaster

Quote:


> Originally Posted by *_02;12137143*
> Nifty!


Thanks.

To the OP, if you need help with batch, I am here for ya.


----------



## Limes

Quote:


> Originally Posted by *Wiremaster;12137120*
> 1. Write a batch file as others have stated to launch the program.
> 2. Use this to make it an .exe
> 3. Run it.
> 
> I have done this all the time. It's awesome.


Thanks, that did the job perfectly. + Rep


----------



## Plex

Quote:


> Originally Posted by *Limes;12137035*
> Sigh...please stop straying away from the original question, and yes if I am running multiple versions of an application, I have to create a new shortcut and add the parameters again due to the fact its in entirely different directories, why should I do that when I can easily drop the new .exe in the same directory.


I'm not straying at all. None of us are. We are trying to figure out your motives so we can help you. If you would have explained that you were trying to make a single portable file that you could drop anywhere then you would have avoided a lot of the questions that everyone had in this thread.
Quote:


> Either way my question isn't should I or should I not, its how can I, I would appreciate it if we could keep the discussion to my original post.


Now that I know why exactly you want a portable .exe, the question isn't "how can I?" it's "can I?" and the answer to that is no, you can't.

Even with the batch method described right above me, you still need that batch file pointing back to the original location (or sitting in the same directory). This is the same thing as the shortcut.

The only way to do it is to have the source code and hard-code the parameters in that you want passed at compile time. That's not going to be easy (read: near impossible) for someone who doesn't have any programming experience.


----------



## _02

Quote:


> Originally Posted by *Plex;12137924*
> The only way to do it is to have the source code and hard-code the parameters in that you want passed at compile time. That's not going to be easy (read: near impossible) for someone who doesn't have any programming experience.


Eh, he can make an EXE or batch that simply executes with parameters in the local path, so that the location is irrelevant as long as this program and the one it calls are in the same directory.

Regardless, I would still use the shortcut but OP has the floor


----------



## Plex

Quote:


> Originally Posted by *_02;12137941*
> Eh, he can make an EXE or batch that simply executes with parameters in the local path, so that the location is irrelevant as long as this program and the one it calls are in the same directory.


Right, but that's my point exactly. He wants to be able to move the executable around and be able to run it from anywhere. (I assume possibly from multiple machines, too?)

The batch file passing parameters to the executable in the same path still won't let you move a single file around and run it from where you want. Thus, it's the exact same thing as a shortcut.


----------



## Wiremaster

Only on OCN do we continue to discuss the question after the OP is satisfied. Most other places the question barely gets answered before the thread dies. Gotta love it here


----------



## Plex

Quote:


> Originally Posted by *Wiremaster;12139260*
> Only on OCN do we continue to discuss the question after the OP is satisfied. Most other places the question barely gets answered before the thread dies. Gotta love it here


Hey, I'm just trying to help the OP







. The batch file method that he is satisfied with isn't accomplishing what he wanted. I figured he tested it and ran it in the same folder as the original and didn't realize that when he goes to move the batch file out, it's not going to work anymore.


----------



## Wiremaster

Quote:


> Originally Posted by *Plex;12139331*
> Hey, I'm just trying to help the OP
> 
> 
> 
> 
> 
> 
> 
> . The batch file method that he is satisfied with isn't accomplishing what he wanted. I figured he tested it and ran it in the same folder as the original and didn't realize that when he goes to move the batch file out, it's not going to work anymore.


If he sets up his batch file correctly, he'll be fine.

For example, the following would launch Program.exe no matter what directory or drive he places it in.

Code:



Code:


cd /d "C:\Program Files\Program Name\"
start Program.exe

Here's the batch file I use to launch my Minecraft LAN server.

Code:



Code:


cd /d "Z:\Minecraft Server"
java -Xmx1024m -Xmx1024m -jar minecraft_server.jar nogui


----------



## Plex

Quote:


> Originally Posted by *Wiremaster;12139508*
> If he sets up his batch file correctly, he'll be fine.
> 
> For example, the following would launch Program.exe no matter what directory or drive he places it in.
> 
> Code:
> 
> 
> 
> Code:
> 
> 
> cd /d "C:\Program Files\Program Name\"
> start Program.exe
> 
> Here's the batch file I use to launch my Minecraft LAN server.
> 
> Code:
> 
> 
> 
> Code:
> 
> 
> cd /d "Z:\Minecraft Server"
> java -Xmx1024m -Xmx1024m -jar minecraft_server.jar nogui


Yes.. I know this. I was under the impression he wanted to move the original file around.

Otherwise, everything you just described is the same thing as a shortcut. You make one single Windows shortcut that points to "C:\Program Files\Program Name\program.exe -a -b -c" and you can move that wherever you want to. Feel me?


----------



## biltong

I know it's been answered but:

srcds.bat:
.\hldsupdatetool.exe -command update -game tf -dir .

Put that in the directory and run it, should work







No need for conversions or anything, if there is a different version of the app just copy paste


----------



## Wiremaster

Quote:



Originally Posted by *Plex*


Yes.. I know this. I was under the impression he wanted to move the original file around.


Moving the file he's _launching_. Got it. Yeah, I don't know any way of doing that.


----------

