Jump to content

I had been spent ages trying to figure out how to open a file that was in the same folder as the bat file, and could be moved to other ones, i worked that out and i wish to share it with others, so they can have a look, i can receive feedback, and so others wishing to do the same can with ease.

The code is:

::This opens file in same directory
pushd %~dp0
ProgramInSameFolderAsBat.exe
popd
::Made By Blake McCullough

It is also available on my github to download:

https://github.com/Blake-McCullough/OpenFileInSameFolderBat

I posted this as a post in the forums so others can easily find it, Please mods leave this thread open so i can get feedback and can help others using this.

UwU

Link to comment
https://linustechtips.com/topic/1248211-openfileinsamefolderasbatfile/
Share on other sites

Link to post
Share on other sites

Also works with

START %0\..\program.exe

 

And I'm pretty sure

START %~dp0\program.exe

works as well.

 

Pushd and popd save the folder you're working in to a stack, they're generally best used to change the working directory and then return to where you were.

¯\_(ツ)_/¯

 

 

Desktop:

Intel Core i7-11700K | Noctua NH-D15S chromax.black | ASUS ROG Strix Z590-E Gaming WiFi  | 32 GB G.SKILL TridentZ 3200 MHz | ASUS TUF Gaming RTX 3080 | 1TB Samsung 980 Pro M.2 PCIe 4.0 SSD | 2TB WD Blue M.2 SATA SSD | Seasonic Focus GX-850 Fractal Design Meshify C Windows 10 Pro

 

Laptop:

HP Omen 15 | AMD Ryzen 7 5800H | 16 GB 3200 MHz | Nvidia RTX 3060 | 1 TB WD Black PCIe 3.0 SSD | 512 GB Micron PCIe 3.0 SSD | Windows 11

Link to post
Share on other sites

On 9/18/2020 at 12:57 PM, BobVonBob said:

Also works with


START %0\..\program.exe

 

And I'm pretty sure


START %~dp0\program.exe

works as well.

 

Pushd and popd save the folder you're working in to a stack, they're generally best used to change the working directory and then return to where you were.

Yeah im sure that could work, just that worked for me when i was making the program.

 

UwU

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×