Solved

How do you pass arguments to a published application?

Posted on 2008-10-08
19
1,058 Views
Last Modified: 2013-11-26
Very easy yet can't figure a way out of it! With VS2003 I used to make a project for my deployment package. But with VS2008 I am now using the excellent feature of publishing my application. Which everything works fine!

The question is, how can I pass a command line argument to my published application? The problem is that every time I publish my application and is installed on the user's computer the installation path changes since the installation is in his documents and settings folder etc.. Previously the installation path was fixed such as
c:\progra~1\MyApp\Test.exe myProc1
In the above case myProc1 would be the argument/parameter being passed in the application

Any ideas people??
0
Comment
Question by:borgb002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 4
  • +1
19 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22671238
is this data to pass fixed? maybe you can put in a "setting variable" instead.
0
 

Author Comment

by:borgb002
ID: 22671273
no sorry. I could pass different parameter values
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22671316
I feel maybe changing parameters constantly is not the best solution for you.
if you will pass differente parameters values, how and when do you will change them?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:borgb002
ID: 22671384
I want to make automation in my program. a very simple scenario. I use windows scheduler to call my application at 8 AM to send an email and at 9 AM to print a document. (theorical example).
Hence I create two batch files that call my application with their respective parameter
0
 

Author Comment

by:borgb002
ID: 22677064
Come on people, no heroes? With over 50,000 experts having 2.3 million proven solutions and no solution yet :))

Let's put it another way. The real idea is to be able to communicate with another programmer that is using Framework 1.1 and is not able to upgrade to the latest framework (for various reasons beyond the scope of this question). I want him to be able to call my application and send particular commands to be able to call particular functions or routines asynchronously i.e. he does not need to receive any feedback, however if there is a way, it would be nice :)

over to you gurus!
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 22677088
Well, you can know the path of the application at runtime, with:
    System.Windows.Forms.Application.ExecutablePath
So, if you configure your scheduled settings at runtime, you can create the batch files with easy.
0
 

Author Comment

by:borgb002
ID: 22681202
Not possible because the other programmer/developer would not be able to determine the path. As regards the schedules created at runtime it looks a bit messy.. no offense.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 22681622
Indeed you have a poor control of this because your are using the Publish Wizard, if you need a better control you should create your own Installer application project. But if you want to keep working with the Publish Wizard you will have to use some create trick.

A common used technique also is:
When you start your application for first time, save the application path into a registry entry.
From your scheduling tool, you can read this path.

0
 

Author Comment

by:borgb002
ID: 22826043
Isn't there some other easier way to communicate with my fellow programmer? Rather than using the registry as a common note ........

To recap:
- He is using framework 1.1.  I'm using Framework 3.5 using VS2008
- I'm using the Publish / Click-once technology. Hence the installation path is dynamic
- There must be a way that he could
1) find the path of my application (since it is not in a standardised folder
2) call my application
3) pass parameter(s)
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 22830987
borgb002,

Because of the way ClickOnce applications are deployed and launched, you have limited choices for programmatically starting your application.  Probably the best way would be to use the manifest URL and pass your parameters that way.  This is described here:

http://briannoyes.net/2004/08/10/HarvestingClickOnceCommandLineArguments.aspx
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22830985
Hi,
1) I dont see any reason he could not search for your application in the file system as the name of the exe does not change.
2) Is there any reason you could not publish a DLL for the other programmer to reference in his application?
3) Is it feasible to make your application run online only and allow URL parameters?
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 22831034
>I dont see any reason he could not search for your application in the file system as the name of the exe does not change.

Because multiple versions will be installed as updates are published.

>Is there any reason you could not publish a DLL for the other programmer to reference in his application?

The same problems exist.  You cannot install to GAC using ClickOnce
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22831243
The suggestion you gave is my point 3; to activate the application from the URL with passing parameters to the URL.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 22831363
>The suggestion you gave is my point 3;

Yes, which is why I didn't comment on your 3rd point, although the link I gave describes it in a lot more detail.
0
 

Author Comment

by:borgb002
ID: 22834767
PaulHews ->  I'll have a look at your link and study it into detail

CodeCruiser:
          1) I dont see any reason he could not search for your application in the file system as the name of the exe does not change.
Right, the exe doesn't change but the running path changes for every publish :(  [this is my biggest prob!]

2) Is there any reason you could not publish a DLL for the other programmer to reference in his application?
Nope the DLL in framework 3.5 didnt work well with 1.1 Have tried it and VS2003 didnt recognise it as a "valid DLL".

3) Is it feasible to make your application run online only and allow URL parameters

I think this is similar to what PaulHews said.... But didn't know that the application can be made "online" ?   What would happen to those offline users working on a laptop? can they then use my application without a network.?
0
 
LVL 38

Assisted Solution

by:PaulHews
PaulHews earned 250 total points
ID: 22835205
>What would happen to those offline users working on a laptop? can they then use my application without a network.?

If you look at your clickonce settings you should see something like this picture.  If you have "Offline as well" selected, then your users will be able to launch your program from the start menu using the installed shortcut.  But while offline, your command line parameters will not be able to be passed via the URL, so your scheduled tasks may fail (if that's how you set them up.)  Even if you figured out the path and created scheduled tasks for your app, when there's an update, all those tasks would be invalid anyway.

ClickOnce has it's uses, but it's also very limited, as Jaime pointed out before.  Given the complications you face, you may want to create a proper setup package or use one of the variations Jaime suggested above.  




Image2.jpg
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
With the internet and the ease of information transference, many professional jobs can be done anywhere today.  Why should it make a difference whether an x-ray is read in India or the United States as long as the radiologist is qualified?   Outso…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question