Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Spoiled_Kitten

OpenFileInSameFolderAsBatFile

Recommended Posts

Posted · Original PosterOP

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.


Blake has arrived!!

Just your local tech geek!

Love to help!

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-3820 | Corsair H100i | ASUS P9X79-LE | 16GB Patriot Viper 3 1866MHz DDR3 | MSI GTX 970 Gaming 4G | 2TB WD Blue M.2 SATA SSD | 2TB Hitachi Deskstar HDD | 1TB WD Black HDD | Corsair CX750M Fractal Design Define R5 Windows 10 Pro / Linux Mint 20 Cinnamon

 

Laptop:

Dell XPS 15 9560 4K Touch | Intel Core i5-7300HQ | 12GB Generic (Crucial?) 2133MHz DDR4 | Nvidia GTX 1050 | 256GB Toshiba M.2 NVMe SSD | Windows 10

Link to post
Share on other sites
Posted · Original PosterOP
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.

 


Blake has arrived!!

Just your local tech geek!

Love to help!

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


×