working Directory problem with RunProgram

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

working Directory problem with RunProgram

Post by skinkairewalker »

hi everyone !

I built a software for socket servers, which worked perfectly on my pc (windows 10), yesterday I put it on a vps (windows server 2012 & windows server 2008R2) test on both, and had the same problem:

I put the system on local disk C:\MainServer\, the program should automatically run a socket tcp server in the folder: C:\MainServer \MyServer\

To run this server in the "C:\MainServer\MyServer\" folder, I used the following command:

Code: Select all

RunProgram(GetCurrentDirectory()+"MyServer\server.exe", "", GetCurrentDirectory()+"MyServer\)
the server running: C:\MainServer\MyServer\server.exe, can't read the settings inside the same folder: C:\MainServer\MyServer\ServerConfig.ini, even if I set the working directory to the same directory: C:\MainServer\MyServer\, what could be happening? already tried everything to solve this, and the only exit I had left was:

Code: Select all

SetCurrentDirectory (GetCurrentDirectory () + "MyServer\")
RunProgram(GetCurrentDirectory()+"MyServer\server.exe", "", GetCurrentDirectory()+"MyServer\)
Delay (10); if I remove the delay, "server.exe" still can not read the local settings (ServerConfig.ini)
SetCurrentDirectory ("C:\MainServer\")
I hope you understand :)
#Sorry by my bad english :c
User avatar
mk-soft
Always Here
Always Here
Posts: 5338
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: working Directory problem with RunProgram

Post by mk-soft »

Perhaps help this...

Code: Select all

Macro GetProgramPath()
  GetPathPart(ProgramFilename())
EndMacro

Debug GetProgramPath() + "MyServer\server.exe"
P.S.
current directory is not always the program directory...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: working Directory problem with RunProgram

Post by skinkairewalker »

thanks you very much :D
Post Reply