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
ic icPosted Oct 2, 2009, 8:44 AM
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() {
??
naura paxPosted Oct 2, 2009, 7:52 AM
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 icPosted Oct 2, 2009, 7:51 AM
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!
??
ic icPosted Oct 2, 2009, 7:06 AM
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
naura paxPosted Oct 2, 2009, 6:44 AM
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 icPosted Oct 2, 2009, 6:22 AM
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 paxPosted Oct 2, 2009, 5:57 AM
besides you can use a string variable
string str=@"......filename.ini";
and pass string in insert
Insert(0,str)
ic icPosted Oct 2, 2009, 4:38 AM
{"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: startIndex"}
naura paxPosted Oct 2, 2009, 4:00 AM
btw in this code-
once again you forgot to specify verbatim @"i:\\app\\test\\WAREH004.ini"
ic icPosted Oct 2, 2009, 3:37 AM
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 paxPosted Oct 2, 2009, 3:11 AM
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 icPosted Oct 2, 2009, 2:36 AM
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 paxPosted Oct 2, 2009, 1:05 AM
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 icPosted Oct 1, 2009, 8:57 AM
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 paxPosted Oct 1, 2009, 8:00 AM
here is one way.
ic icPosted Oct 1, 2009, 7:39 AM
Reall yapprecaite any help - because I'm searching all over the net for solutions :)
ic icPosted Sep 29, 2009, 5:40 AM
public frmWAREH010() - Also has no arguments!
Roei BarPosted Sep 29, 2009, 5:24 AM
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