Passing Parameters to an Exe

J

JTC^..^

I would like to pass a parameter (with or without using a windows
service), so the user can be taken to a particular form when opening
the application.

The user recieves an email notification containing the information
they need, this additionally contains a link to the publish.htm, as
the application is delpoyed using the click once.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


What place has a "Windows Service" in your escenario?

You can start your app with a parameter that indicates where to go. That is
easy.

Could you give more details about your problem?
 
F

Family Tree Mike

For parameters, I prefer to use Environment.GetCommandLineArgs(), as it is
available anywhere in your code. Alternatively, your "Main" can accept a
string array to get the args.

As to the rest of your question, that is all dependent on how your forms
work. You need to clarify what you are asking, I believe.
 
J

JTC^..^

I've only seen solution that use a windows service to start the
application with parameters.

I'm sure I've done this before but a couple of years ago when learning
C#, but I can't remember how.

The scenario is that the user will need to provide the application
with a ProductCode and WorkflowStage parameter, to take them to the
correct form.


Thanks for your reply.
 
J

John B

JTC^..^ said:
I would like to pass a parameter (with or without using a windows
service), so the user can be taken to a particular form when opening
the application.

The user recieves an email notification containing the information
they need, this additionally contains a link to the publish.htm, as
the application is delpoyed using the click once.

You would pass parameters when you start your exe
ie myexe.exe /p1 /p2 /p3 /p4

If you defined your main as:
void main(params string[] args)
you would then be able to access /p1 /p2... in the array.

If you are using clickonce though, you need to look at the "Allow URL
Parameters.." option of the publish options page.
You also need to deal differently with parameters in that case, google
for clickonce parameters and it should give you some links.

JB
 
L

Luc E. Mistiaen

but the underlying system service call to start a service does, and you
could easily write a little command to start a service with an argument
list...

/LM

BOOL WINAPI StartService(
__in SC_HANDLE hService,
__in DWORD dwNumServiceArgs,
__in_opt LPCTSTR* lpServiceArgVectors <---<<
);
 
W

Willy Denoyette [MVP]

net start <name> dont take parameters...


don't use "net" to control services from the command line, use sc.exe
instead.
For instance "sc start " takes arguments.
See help sc for details.

Willy.
 
C

christery

don't use "net" to control services from the command line, use sc.exe
instead.
For instance "sc start " takes arguments.
See help sc for details.

Willy.

And where has that command been all my life... thanks Willy
 
Joined
Nov 22, 2008
Messages
1
Reaction score
0
I was looking for service passing parameters also. I found hits on the internet suggesting net start would work like this, but it doesn't work for me:
net start MyService /parm1 /parm2 ...
As you say, sc works very well, but there is one desired behavior for net start that I lose when switching. Our use case is a batch file that starts several services, but some of the services must be fully started before others are started. In the batch file, net start will show that the start command waits for the start to complete. It even puts up trailing periods so you can see it is actively starting.

Sadly, sc does not have this property, it appears to send the control command and returns immediately with the service status, which is usually "starting".

Anybody know of a way start services with parameters and have each start wait for completion before it returns?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top