Setting a BAT to open a file BY DRAGGING THE FILE ON THE BAT

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
alesimula
Posts: 11
Joined: 15 Oct 2014 09:14

Setting a BAT to open a file BY DRAGGING THE FILE ON THE BAT

#1 Post by alesimula » 15 Oct 2014 09:22

Sorry if i've already made this questions on yahoo answers, but i think this forum would give better answers.

Basically what i want to do is to make a BAT file open a file that's dragget to it or opened with it with another application
BUT VIA SUFFIX in this way:

START whatdoihavetotypehere.exe -loadbin "OPENEDFILEPATH" <<< that's the opened file

^ that's another file with a SPECIFIC path, wich is located in the same folder of the bat file

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#2 Post by Squashman » 15 Oct 2014 10:21

The file you drag and drop onto the batch file can be referenced in the batch file as: "%~1"

alesimula
Posts: 11
Joined: 15 Oct 2014 09:14

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#3 Post by alesimula » 15 Oct 2014 10:27

yes but that doesn't tell me everything, i still don't know how can i open that specific exe file USING THOSE PARAMETERS

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#4 Post by Squashman » 15 Oct 2014 10:49

alesimula wrote:yes but that doesn't tell me everything, i still don't know how can i open that specific exe file USING THOSE PARAMETERS

Not sure how you would open up an exe file. It would be a binary file. What would you expect to read from opening an exe file?

Maybe I just don't understand what you want. Maybe if your description was more detailed to show a more detailed example then we could figure it out.

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#5 Post by ShadowThief » 15 Oct 2014 11:04

So you want to run waffles.exe by dragging it onto the batch script and then the batch script will run

Code: Select all

start waffles.exe -loadbin "<current path of waffles.exe>"


Am I reading that correctly?

alesimula
Posts: 11
Joined: 15 Oct 2014 09:14

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#6 Post by alesimula » 15 Oct 2014 11:12

ShadowThief wrote:So you want to run waffles.exe by dragging it onto the batch script and then the batch script will run

Code: Select all

start waffles.exe -loadbin "<current path of waffles.exe>"


Am I reading that correctly?


NOT EXACTLY
drag potato.bin inside loader.bat
should do something like

start waffles.exe -loadbin "<current path of potato.bin>"

And remember waffles.exe is in the same directory as loader.bat, while potato.bin is in a random directory

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#7 Post by ShadowThief » 15 Oct 2014 11:15

Will that same exe always be run regardless of which file is dragged onto the batch script?

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#8 Post by Compo » 15 Oct 2014 11:20

Code: Select all

@If /I %~x1 Equ .bin (Start waffles.exe -loadbin "%~1")

alesimula
Posts: 11
Joined: 15 Oct 2014 09:14

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#9 Post by alesimula » 15 Oct 2014 11:32

Compo wrote:

Code: Select all

@If /I %~x1 Equ .bin (Start waffles.exe -loadbin "%~1")


Problem is, this would result as waffles.exe is in the same folder as potao.bin

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#10 Post by ShadowThief » 15 Oct 2014 11:38

alesimula wrote:
Compo wrote:

Code: Select all

@If /I %~x1 Equ .bin (Start waffles.exe -loadbin "%~1")


Problem is, this would result as waffles.exe is in the same folder as potao.bin

But you said earlier that waffles.exe is in the same folder as the batch script.

alesimula
Posts: 11
Joined: 15 Oct 2014 09:14

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#11 Post by alesimula » 15 Oct 2014 11:43

ShadowThief wrote:
alesimula wrote:
Compo wrote:

Code: Select all

@If /I %~x1 Equ .bin (Start waffles.exe -loadbin "%~1")


Problem is, this would result as waffles.exe is in the same folder as potao.bin

But you said earlier that waffles.exe is in the same folder as the batch script.


Yes, but dragging potato.bin (wich is in a random folder) inside te bat file, will result as path is potato's path and not bat file's path

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#12 Post by Squashman » 15 Oct 2014 11:47

ShadowThief wrote:But you said earlier that waffles.exe is in the same folder as the batch script.

Exactly. The current working directory will be where the batch file resides. Not the directory of the file you drag onto the batch file.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#13 Post by Squashman » 15 Oct 2014 11:51

Make this batch file and drop any file you want onto it.

Code: Select all

@echo off
echo This is the batch file path: "%~dp0"
echo This is the current working directory: "%CD%"
echo This is the file names path: "%~dp1"
pause

alesimula
Posts: 11
Joined: 15 Oct 2014 09:14

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#14 Post by alesimula » 15 Oct 2014 11:53

Squashman wrote:
ShadowThief wrote:But you said earlier that waffles.exe is in the same folder as the batch script.

Exactly. The current working directory will be where the batch file resides. Not the directory of the file you drag onto the batch file.


facts proves the contrary: when i drag potato.bin inside the bat, it says waffle.exe doesn't exist, while it runs when poteto.bin is in the same folder as waffles.exe

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Setting a BAT to open a file BY DRAGGING THE FILE ON THE

#15 Post by ShadowThief » 15 Oct 2014 11:56

What happens if you say

Code: Select all

@If /I %~x1 Equ .bin (Start "%~dp0\waffles.exe" -loadbin "%~1")

Post Reply