|
-
February 26th, 2006, 03:41 PM
#1
Running a program via a remote program
My program runs another program, which the user has to choose.
The problem is that the program which needs to be runned, needs other files (like dll files).
When my program is in another folder (e.g., my program is located at C:\Program Files\myprogram.exe, the targeted program is in D:\Program Files\targetedprogram.exe), the targeted program tries to find those dll files in C:\Program Files\ , but these files aren't there of course.
Any help how to let the targeted program look for his dll files in D:\Program Files ?
Please help!
-
February 27th, 2006, 12:36 PM
#2
Re: Running a program via a remote program
I am assuming that the exe you are trying to run are .NET assemblies.
If that is true, then all the dlls must be in the same directory as the exe, or in the GAC (Placing Assemblies in the Global Assembly Cache).
There are other advanced way of telling the exe the exact locations of dll (such as probing and code base, check out google).
Also check this: http://www.codeproject.com/dotnet/as...deployment.asp
-
February 27th, 2006, 12:54 PM
#3
Re: Running a program via a remote program
I thought of something like my program copying a small program into the targeted program's folder, is that possible?
That small program would then exec the targeted exe, including all other files.
Or maybe it can be done with a bat file?
(please give the command for execing a program in a bat file)
-
February 27th, 2006, 04:33 PM
#4
Re: Running a program via a remote program
Use File.Copy to copy any file you need to the target folder.
In order to run the program:
Code:
Process.Start("C:\\1.exe"); // or whatever folder
If you wish to do it in a bat file:
You can run bat files the same way.
Maybe the bat file will look like this:
Code:
copy C:\SourcePath\file.exe C:\TargetPath
...
C:\\1.exe
-
February 27th, 2006, 04:44 PM
#5
Re: Running a program via a remote program
Thanks for the help, the problem's almost solved, but my question about the bat file was, what's the command in the bat file to run a program (like in my program its Process.Start), and is it possible to temporarly copy the bat file to the targeted folder, and when that program has started, remove the bat file again.
-
February 28th, 2006, 02:59 AM
#6
Re: Running a program via a remote program
In order to start a program in a bat file you need to simply type the name of the exe. If you want you can include full path. You might want to include command line arguments.
For example:
Code:
notepad
copy x.bat C:\Target\y.bat
This will start notepad and copy a file.
You can use the word "start" if you wish to wait till the program finished before continueing.
Code:
notepad
start notepad
notepad
The third notepad will only run after the second one is closed.
Of course you can delete the batch file after it is finished (use File.Delete). If you try to delete the bat file when it is running you will get an exception.
-
February 28th, 2006, 03:08 AM
#7
Re: Running a program via a remote program
IMO, a batch file is at least a collection of commands that you can run under command prompt (similar to the shell scripts that you have for unix). So, the commands that you need to run an application from command prompt can be put into that batch file and that file can be run on cmd prompt. If you don't want to set the whole path of the exe in the batch file - you may want to set the environment variable "path" for the application on windows. Regards.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
February 28th, 2006, 04:30 AM
#8
Re: Running a program via a remote program
 Originally Posted by jhammer
Of course you can delete the batch file after it is finished (use File.Delete). If you try to delete the bat file when it is running you will get an exception.
When does the batch file stop running: when all the commands are completed, or do I need a command like Quit to stop it?
-
February 28th, 2006, 05:32 AM
#9
Re: Running a program via a remote program
Calling exit would exit the command prompt.. you can leave it to that.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
February 28th, 2006, 05:53 AM
#10
Re: Running a program via a remote program
Thanks, almost done.
Only the very last questions:
how can I via .NET change the extension of a file? (because I will use streamwriter to creater a file program.txt, and rename it to program.bat)
Or can the streamwriter write as well in a .bat file?
And when you rightclick on a shortcut you can change the target (e.g. for the game Wolfenstein Enemy Territory, the game I make this program for I have this target, it also runs a mod (etpro) and an extra script (MasterScript.cfg):
Code:
"C:\Program Files\En. Territory\ET.exe" set fs_game etpro + exec MasterScript.cfg
Can I do this with a batch file as well?
Last edited by StevDevil; February 28th, 2006 at 06:13 AM.
-
February 28th, 2006, 12:39 PM
#11
Re: Running a program via a remote program
 Originally Posted by jhammer
Use File.Copy to copy any file you need to the target folder.
In order to run the program:
Code:
Process.Start("C:\\1.exe"); // or whatever folder
If you wish to do it in a bat file:
You can run bat files the same way.
Maybe the bat file will look like this:
Code:
copy C:\SourcePath\file.exe C:\TargetPath
...
C:\\1.exe
Please tlle me what's wrong with the following code (it's all that I have that's gotta do with the File.Copy):
Code:
File.Copy("ETBat.bat",etLocation);
etLocation is a string which contains the location to where ETBat.bat has to be copied.
Please help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|