open fil in same catalog as .exe file

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2008
Posts: 3
Reputation: lordsvae is an unknown quantity at this point 
Solved Threads: 0
lordsvae lordsvae is offline Offline
Newbie Poster

open fil in same catalog as .exe file

 
0
  #1
Feb 17th, 2008
Allright, this is the deal, im trying to use Install Sheild to install a program I wrote in java. But I cannot make shortcuts on the desktop and/or START menu linking to the .jar file, it has to be a .exe file, so I need to make a simple .exe file so I can have shortcuts. this is my simple program so far:

  1. #include "stdafx.h"
  2.  
  3. using namespace System;
  4. using namespace System::Diagnostics;
  5.  
  6. int main(array<System::String ^> ^args)
  7. {
  8. Process^ minProsses = gcnew Process;
  9. ProcessStartInfo^ minProssesStartInfo = gcnew ProcessStartInfo("\\test.jar");
  10. minProsses->StartInfo = minProssesStartInfo;
  11. minProsses->Start();
  12. return 0;
  13. }

but it doesn't seem to find the .jar file, might be that the address is wrong and it doesn't accept \\ to be the folder itself is in.

So there is one thing, it doesn't know what folder it is in, since people can install it where they want, so I cannot really set the shortcut to be "C:\\Program Files\\MyProg\\test.jar". It has to be like this; "CurrentDirectory" + "\\test.jar" or something.

Really hope someone here can help me out, since I've already tried 2 other forums.
And yes, I'm not so good with C++, just a small course at school, but this should be easy, but I can't seem to find the answer.

thx for your help
LordSvae
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: open fil in same catalog as .exe file

 
0
  #2
Feb 17th, 2008
> It has to be like this; "CurrentDirectory" + "\\test.jar" or something.
so just use a relative path "test.jar". and put the .exe and the .jar in the same folder.
  1. ProcessStartInfo^ minProssesStartInfo =
  2. gcnew ProcessStartInfo( "test.jar" ) ;
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 3
Reputation: lordsvae is an unknown quantity at this point 
Solved Threads: 0
lordsvae lordsvae is offline Offline
Newbie Poster

Re: open fil in same catalog as .exe file

 
0
  #3
Feb 17th, 2008
ok listen, it works. Though not when you use Visual Studio to compile it, then it doesn't work. Dunno if it uses the .exe file after its compiled, but when I took the .exe file and put it in the folder with the .jar file, it worked. So there, its solved.

allthough, vista doesn't accept the .exe file, doesn't want to run it, gives me some kind of error message. But doesn't matter. XP is the OS for me anyways.
Last edited by lordsvae; Feb 17th, 2008 at 11:11 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,089
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Solved Threads: 164
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: open fil in same catalog as .exe file

 
0
  #4
Feb 17th, 2008
> it works. Though not when you use Visual Studio to compile it, then it doesn't work.
you really mean, when you run it from inside Visual Studio.
the reason is that in this case, the current directory of the process is the project directory, not the director(y/ies) where the executable file is located
Last edited by vijayan121; Feb 17th, 2008 at 11:20 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC