Running files from the same folder has the .exe file

Hi everyone.
I have a biginner question and I hope that someone could help me.
I have a .exe file and a .bat file in the same folder.
I want to make that a bottom could open the .bat file, but I dunno the way to open it.
Process.Start("???")
I thought that it was ...\\batfile.bat but it doesn't work.
How can I run the file that it on the same folder that the .exe file?
Tnks.
Last edited on
What do you mean by "run" the .txt file?

When your .exe is run, it need not be invoked from the same folder that it is in. There are a couple of ways to fix this, but on Windows you can just ask for your .exe's file name:

1
2
3
4
5
6
7
8
9
10
#include <string>
#define NOMINMAX
#include <windows.h>

std::string where_is_my_exe()
  {
  char filename[ MAX_PATH ];
  DWORD length = GetModuleFileNameA( NULL, filename, MAX_PATH );
  return std::string( filename, length );
  }

Use the functions found here to get at pieces of the path:
http://www.cplusplus.com/forum/beginner/1962/#msg7180

Hope this helps.
Last edited on
Nop...
I will explaind better.
I wanna go to the same path that my .exe file is, so I'v wroten:
Process.Start("../batfile.bat")
But it doesn't work.
How can I make it work?
Same stuff I said:

1
2
string path = ExtractDirectory( where_is_my_exe() ) + "batfile.bat";
Process.Start( path.c_str() );
Topic archived. No new replies allowed.