Hi I start a proccess like this: ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// string strStartMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); try { System.Diagnostics.Process SetupGUIProcess = new System.Diagnostics.Process(); SetupGUIProcess.StartInfo.FileName = strStartMenuPath + "\\Programs\\AXYZ International\\A2MC Setup.appref-ms"; SetupGUIProcess.StartInfo.Arguments = "192.168.0.52 Why is it one"; SetupGUIProcess.Start(); // System.Diagnostics.Process.Start(strStartMenuPath + "\\Programs\\AXYZ International\\A2MC Setup.appref-ms", "192.168.0.52");//AddressBar.GetIPAddress()); } catch(System.Exception f) { MessageBox.Show("A2MC Setup.exe Not Installed\n" + f.ToString()); }
/////////////////////////////////////////////////////////////////////////////// I have tried a number of different ways to get the command line arguments like this
/////////////////////////////////////////////////////////////////////////////////////////////////// public static void Main(String[] moreargs)
{
string command = Environment.CommandLine;
MessageBox.Show(command);
foreach (string morearg in moreargs)
{
MessageBox.Show(morearg.ToString());
}
string[] args = Environment.GetCommandLineArgs();
foreach (string arg in args)
{
MessageBox.Show(arg.ToString());
}
MessageBox.Show("arg.Length = " + args.Length.ToString());
///////////////////////////////////////////////////////////////////////////
How do I retreive the command line arguements? Am I not passing them correctly? or Am I not recieving them correctly? Can someone please explain how to do this?
Don - Moved bynobugzMVP, ModeratorWednesday, September 30, 2009 10:04 PM (From:Visual C# General)
-
| | DonJuna Wednesday, September 30, 2009 7:49 PM | First, your application has to be an online-only application. You can not deploy it as online/offline. Second, you have to use the installation URL, not the link to the appref-ms file. It's a query parameter, like for an internet link? This will probably be helpful to you: How to retrieve query string information http://msdn.microsoft.com/en-us/library/ms172242(VS.80).aspxRobinDotNet Click here to visit my ClickOnce blog!- Marked As Answer byAland LiMSFT, ModeratorMonday, October 05, 2009 9:56 AM
-
| | RobinDotNet Thursday, October 01, 2009 2:19 AM | Not to put too fine a point on it, but I would do it just like the example on the 1st page of that article I posted a link to. http://myserver.companycom/myapplicationfolder/myapplicationname.application/?firstparam=thisvalueMake your application an online-only application. Then add some code to check for the query parameter (there's an example in that article too). You could also store the data in a file somewhere. I would put it in LocalApplicationData, which is the recommended location for this kind of thing. You might want to create a folder for your company, and then you can keep all kinds of info there. string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string myFolder = Path.Combine(userFilePath, "MyCompany"); if (!Directory.Exists(myFolder)) Directory.CreateDirectory(myFolder); //now create your file in myFolder Then you can use the shortcut on the start menu to run the other application. shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", publishingcompany, "\\", productname, ".appref-ms"); Process.Start(shortcutName); (It seems easier to use query parameters. :-) Robin Click here to visit my ClickOnce blog!Microsoft MVP - Proposed As Answer byRobinDotNetMVP, ModeratorSunday, October 04, 2009 6:41 PM
- Marked As Answer byAland LiMSFT, ModeratorMonday, October 05, 2009 9:55 AM
-
| | RobinDotNet Friday, October 02, 2009 2:56 AM | Passing command line arguments to a ClickOnce installed app is a bit tricky. Run this google query, the first hit looks good.
Hans Passant. | | nobugz Wednesday, September 30, 2009 8:02 PM | Hi,
I presume the string "Why is it one" in your aguments is intended to be a single arugment to the msi... in which case you'll need to wrap it in " characters, i.e
"192.168.0.52 \"Why is it one\"";
You may or may not need to do the same thing with IP... I don't think you do since it doesn't contain spaces (and I think. is legal), but it might be worth a try if you continue to have problems.
Hans' link should help you figure out how to receive the arguments inside the installer. Like he said, it can be tricky, especially if there is an exe based bootstrapper on the front of the MSI etc. as these sometimes don't forward the arguments to the installer process. | | Yort Wednesday, September 30, 2009 8:35 PM | Thanks for replying Hans. Can you pleasa provide a link to the solution? I think what you are asking me to do is google the string Passing command line arguments to a ClickOnce installed app is a bit tricky I did that and the first link I get is http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/7a53f8f6-4396-4e68-bf62-4c3d00860fdbwhich does not explain what I am looking for. Sorry I don't get it Please can you show me an example of how to start a ClickOnce installed app and pass it some arguments and then retrieve them inside the app?
Don | | DonJuna Wednesday, September 30, 2009 8:39 PM | I turned the "google query" in a hyperlink, just click it. This is the first hit. That's a hyperlink too, just click it.
Hans Passant. | | nobugz Wednesday, September 30, 2009 8:44 PM | Thanks for the reply,
I basically can't get any arguments from calling app to the called app. I am not trying to pass arguments from an installer. Just from one application installed calling the other that is installed
Sorry I'm lost on this one. Don | | DonJuna Wednesday, September 30, 2009 8:46 PM | Ok, in which case if you change the declaration of your 'main' method in Program.cs of the called application to be;
static
void Main(string[] args)
Then args should be an array of string values containing the arguments. I haven't done this for a while so I might be wrong, but I think the first argument (args[0]) is usually the full path of the program, and the arguments after that are the actual parameters passed in.
There is also a snippet in VS that has some code to process command line arguments in a better way, and a large number of command line argument samples on www.codeproject.com.
Is that what you needed ?
Did you try adding the quotes to the string in the calling app, as suggested ?
| | Yort Wednesday, September 30, 2009 8:51 PM | | | DonJuna Wednesday, September 30, 2009 8:51 PM | all I every get is arg[0] which is the full path but nothing else Don | | DonJuna Wednesday, September 30, 2009 8:53 PM | First, your application has to be an online-only application. You can not deploy it as online/offline. Second, you have to use the installation URL, not the link to the appref-ms file. It's a query parameter, like for an internet link? This will probably be helpful to you: How to retrieve query string information http://msdn.microsoft.com/en-us/library/ms172242(VS.80).aspxRobinDotNet Click here to visit my ClickOnce blog!- Marked As Answer byAland LiMSFT, ModeratorMonday, October 05, 2009 9:56 AM
-
| | RobinDotNet Thursday, October 01, 2009 2:19 AM | Thankyou very much for your reply.
I can't believe how hard it is to launch an application from another and pass it a number which is all I need to do. I think I will just use a file and be done with it. I am still interested in how you would call up the installation URL? with some parameters? Don- Marked As Answer byAland LiMSFT, ModeratorMonday, October 05, 2009 9:55 AM
- Unmarked As Answer byAland LiMSFT, ModeratorMonday, October 05, 2009 9:56 AM
-
| | DonJuna Thursday, October 01, 2009 1:12 PM | Just don't use ClickOnce deployment if you want to make it easy.
Hans Passant. | | nobugz Thursday, October 01, 2009 1:21 PM | Not to put too fine a point on it, but I would do it just like the example on the 1st page of that article I posted a link to. http://myserver.companycom/myapplicationfolder/myapplicationname.application/?firstparam=thisvalueMake your application an online-only application. Then add some code to check for the query parameter (there's an example in that article too). You could also store the data in a file somewhere. I would put it in LocalApplicationData, which is the recommended location for this kind of thing. You might want to create a folder for your company, and then you can keep all kinds of info there. string userFilePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string myFolder = Path.Combine(userFilePath, "MyCompany"); if (!Directory.Exists(myFolder)) Directory.CreateDirectory(myFolder); //now create your file in myFolder Then you can use the shortcut on the start menu to run the other application. shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\", publishingcompany, "\\", productname, ".appref-ms"); Process.Start(shortcutName); (It seems easier to use query parameters. :-) Robin Click here to visit my ClickOnce blog!Microsoft MVP - Proposed As Answer byRobinDotNetMVP, ModeratorSunday, October 04, 2009 6:41 PM
- Marked As Answer byAland LiMSFT, ModeratorMonday, October 05, 2009 9:55 AM
-
| | RobinDotNet Friday, October 02, 2009 2:56 AM | | | RobinDotNet Friday, October 02, 2009 2:57 AM |
|