Click here to Skip to main content
15,886,106 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to run bat file with executable .exe shortcut windows lnk

What I have tried:

i try many ways but cannot worked
Posted
Updated 28-Apr-21 18:24pm
Comments
Patrice T 14-Sep-19 15:36pm    
Describe what is exactly your problem.
RickZeeland 14-Sep-19 16:25pm    
Can you show us the batch file code ?

1) Create your .BAT file:
DoDir.bat
dir >D:\temp\DirContent.txt

2) Right click the desktop, select "New...Shortcut".
3) Browse to the location you save the .BAT file:
D:\Temp\dodir.bat

4) Click Next
5) Click Finish
6) Double click the shortcut.
7) check for the output file:
DirContent.txt
Volume in drive D is [DELETED]
 Volume Serial Number is [DELETED]

 Directory of D:\Temp

15/09/2019  08:38    <DIR>          .
15/09/2019  08:38    <DIR>          ..
12/09/2019  11:33               214 .NETFramework,Version=v4.6.2.AssemblyAttributes.cs
15/09/2019  06:43           151,518 AdobeARM.log
08/09/2019  13:12           559,480 AndroidDesigner551023013106060069.dll
08/09/2019  13:12         6,000,640 AndroidDesigner551023013106060069.pdb
08/09/2019  15:12             2,236 application_data.xml
15/09/2019  06:32                 0 aria-debug-14180.log
01/09/2019  12:18    <DIR>          Autodesk
...
 
Share this answer
 
Comments
MasterGamerFX 16-Sep-19 0:27am    
It is not my asked for
In right click on shortcut right?
In properties window there is target text field right? Where is the path right?
I want to add parameter that executable external like .bat file with the shortcut
OriginalGriff 16-Sep-19 3:16am    
Then you need to explain in full detail exactly what you are trying to do, what you have tried, and where you are stuck. We can't see your screen, access your hard drive, or read your mind - so you need to tell us exactly what you are doing for us to help. Is this a LNK file you are trying to create for code, - if so what language - or what?
We don't know these things unless you tell us!
Maciej Los 17-Sep-19 9:47am    
5ed!
If you want to run executable file from .bat script, you have to add single line:
VB
start /d "path" file.exe


More details, you'll find here: Start - Start a program - Windows CMD - SS64.com[^]

[EDIT]
If you want to add a shortcut to .bat file, follow the instruction:
1) Click right button of mouse on the desktop
2) Choose "New->Shortcut"
3) Follow the wizard
That's all!

By The Way: OriginalGriff[^] already have told how to achieve that (see points 2-5)
 
Share this answer
 
v3
Comments
MasterGamerFX 17-Sep-19 8:39am    
i mean to this:
https://imgur.com/GlFca2t
Maciej Los 17-Sep-19 9:31am    
Answer has been updated. Please check out.
MasterGamerFX 19-Sep-19 8:14am    
no, not my ask
i am looking for line parameter to add this shortcut path that allow run together .bat
file with shortcut when i run shortcut (like OCCT.Ink)
such:
-run ,-any paramater ??
MasterGamerFX 21-Sep-19 5:12am    
You understand?
Maciej Los 24-Sep-19 6:17am    
I'm affraid i do not understand you...
I know this is old thread but I am looking for the same solution. I think what he want to accomplish is to add a bat file as a lauch parameter for a specific app shortcut LNK. Like for example, When running a game like counterstrike, he wants to add a specific bat file in launch parameter to run that bat file first before running counterstrike.exe.

My solution is to edit the bat file and add a run command to the specific app you want to run and create a shortcut for that bat file using the icon of the app you wanted to run.

But as the OP wanted, it would be nice if it can be accomplish using launch parameter for that matter.
 
Share this answer
 
Comments
Dave Kreskowiak 8-Sep-20 22:27pm    
You can't. The shortcut will only launch a single command line. Unless the .EXE you launch accepts a batch file as a parameter and knows what to do with it, you have no choice but to put the CounterStrike launch command at the end of the batch file.
The way to do it is to:
1. Create the batch file
2. Create the batch file shortcut
3. Right-click the shortcut and select 'Properties'
4. Under the Shortcut tab change the 'Target': Add Explorer.exe in front of the batch path

Odd eh? But it works!
Another advantage of doing this is you can now pin the shortcut to the start menu and the taskbar.
 
Share this answer
 
This is a new way that I have never seen before. I did it today.
How it works? The lines written below are used as file names. The file extension is unimportant or may not exist at all. It is important to right-click to launch the file using Windows Powershell.
For permanent use, I doubt it, it is necessary to use a rare extension. For example, .zzz and register it as constantly opened using Powershell.

to open a directory C:\Windows
(New-Object -ComObject Wscript.Shell).Run('explorer C'+[char]58+[char]92+'Windows'+[char]92,1,'false')

to start C:\Windows\notepad.exe
(New-Object -ComObject Wscript.Shell).Run('explorer C'+[char]58+[char]92+'Windows'+[char]92+'notepad.exe',1,'false')
(New-Object -Com WScript.Shell).Exec('notepad')

to open https://github.com
(New-Object -ComObject Wscript.Shell).Run('explorer https'+[char]58+[char]47+[char]47+'github.com',1,'false')

msgBoxs
-c (New-Object -ComObject Wscript.Shell).popup('ItsFunny!',0,'☺')
-c ((New-Object -ComObject ('htmlfile')).parentWindow).alert('☺')
 
Share this answer
 
v7
Comments
Dave Kreskowiak 26-Jan-24 19:13pm    
What the OP was looking for, way back then, was to run a .bat file from the SAME SHORTCUT as a game's launcher. Chances are really high you can't do that because the game shortcut is using a protocol handler, like steam://... The OP would have had to write a new batch file to launch the game, then launch whatever he wanted to start using the batch file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900