Good day, I got calling another program working.
string root = Application.StartupPath;
string exePath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.exe");
string argPath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.INI");
Process.Start(exePath, argPath + " 1");
I need help:
The program i'm calling has the same load form that the current one uses.
1. How do i bypass the load form & load the main form with the forms values i selected on the current program?
2. How do i also pass values to the called programs textbox & click a button?
Please Assist!
Loading

Roei BarRank #1,271 · 1.4K reputationPosted Sep 29, 2009, 1:24 AM EDT
and if so load the form based on the args information
the exe has on Program.cs on the Main Method args in the method signature
check if its not empty and if so work with the information in it
ic ic80 reputationPosted Sep 29, 2009, 1:40 AM EDT
public frmWAREH010() - Also has no arguments!
ic ic80 reputationPosted Oct 1, 2009, 3:39 AM EDT
Reall yapprecaite any help - because I'm searching all over the net for solutions :)
naura paxRank #2,843 · 502 reputationPosted Oct 1, 2009, 4:00 AM EDT
here is one way.
ic ic80 reputationPosted Oct 1, 2009, 4:57 AM EDT
I cant seem to get the file location working on this method:
//string root = Application.StartupPath;
//string exePath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.exe");
//string argPath = System.IO.Path.Combine(root, "i:\\app\\test\\WAREH004.INI");
//Process.Start(exePath, argPath + " 1");
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "i:\\app\\test\\WAREH004.exe" + " i:\\app\\test\\WAREH004.INI" + " 1";
p.StartInfo.Arguments.Insert(0, txtSite.Text);
p.Start();
naura paxRank #2,843 · 502 reputationPosted Oct 1, 2009, 9:05 PM EDT
what are you doing here:
you should add just one filename and that too of an executable. And please use verbatim before a string with special characters.
ic ic80 reputationPosted Oct 1, 2009, 10:36 PM EDT
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe i:\\app\\test\\WAREH004.ini 1";
p.StartInfo.Arguments.Insert(0, txtSite.Text);
p.Start();
naura paxRank #2,843 · 502 reputationPosted Oct 1, 2009, 11:11 PM EDT
try and understand..
"i:\\app\\test\\WAREH004.exe i:\\app\\test\\WAREH004.ini 1" is not a filename
it looks like dos command rather
you will have to specify "i:\\app\\test\\WAREH004.exe" as filename and insert 2 arguments using insert method of the Process.Args
for "i:\\app\\test\\WAREH004.ini" and "1".
I hope i'm clear now.
ic ic80 reputationPosted Oct 1, 2009, 11:37 PM EDT
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe";
p.StartInfo.Arguments.Insert( 1, "i:\\app\\test\\WAREH004.ini");
The other problem is that this would take me to the startup from of the other program & want to bypass this startup frm because it is the same statup frm of the current application & pass the value I selected on the current startup frm to the other program?
Please Help?
naura paxRank #2,843 · 502 reputationPosted Oct 2, 2009, 12:00 AM EDT
btw in this code-
once again you forgot to specify verbatim @"i:\\app\\test\\WAREH004.ini"
ic ic80 reputationPosted Oct 2, 2009, 12:38 AM EDT
{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: startIndex"}
naura paxRank #2,843 · 502 reputationPosted Oct 2, 2009, 1:57 AM EDT
besides you can use a string variable
string str=@"......filename.ini";
and pass string in insert
Insert(0,str)
ic ic80 reputationPosted Oct 2, 2009, 2:22 AM EDT
Unsuccessfull, the 0 index opens only the exe & if i put the 1 in then i get the same error as previous.
string str = @"i:\\app\\test\\WAREH004.ini";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe";
p.StartInfo.Arguments.Insert(0, str);
p.Start();
naura paxRank #2,843 · 502 reputationPosted Oct 2, 2009, 2:44 AM EDT
just insert another argument
Insert(1,"1");
and don't add "1" after the .ini filename. I think that's what you are doing.
and please mark as answered if you get it this time. :)
ic ic80 reputationPosted Oct 2, 2009, 3:06 AM EDT
string str = @"i:\\app\\test\\WAREH004.ini";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"i:\\app\\test\\WAREH004.exe";
p.StartInfo.Arguments.Insert(1, "1");
p.Start();
I tried: Insert(0, "1"); Insert(0, "1" + str); Insert(1, "1" + str); Insert(0, str + " 1");
if i put a break and i pass the insert i can see the arguments are blank
ic ic80 reputationPosted Oct 2, 2009, 3:51 AM EDT
I got it to pass the arguments by removing the insert: p.StartInfo.Arguments = str + @" 1";
The problem i now have is that it calls the login frm the first frm & the same frm my current one has already completed.
I would like to bypass the login load frm and go straight to the Main frm of the other program!
??
naura paxRank #2,843 · 502 reputationPosted Oct 2, 2009, 3:52 AM EDT
you are inserting arguments in a list so it should be like
Insert(0,str);
Insert(1,"1"); two statements one after another.
args is a collection of arguments
in the end it will execute like this-- programname "arg1" "arg2".
I hope you get it this time.
ic ic80 reputationPosted Oct 2, 2009, 4:44 AM EDT
also tired both after one another:
p.StartInfo.Arguments.Insert(0, str);
p.StartInfo.Arguments.Insert(1, "1");
could it be that the program i'm calling does not have arguments setup:
public frmWAREH004S() {
??