0

Possible Duplicate:
Launching a Application (.EXE) from C#?

I am trying to run an exe as a process from my C# code. The exe is a secure one and asks for a password before executing the command. I am unable to pass the password to the exe by any means. When i try to write a standard input it does not take it. Have anyone faced this kind of an issue. If so pls share your work arounds for the scenario. Thanks in advance

I am editing the post to make it a little clear. The exe that i am trying to run is a command line exe. Its a white listing tool provided by mcafee. What i am trying to do is to set the password to the exe so that i can make it secure. the command goes like this

sadmin passwd

once i execute the command it will ask me for the password i want to assign

new password:

once i enter the password it will ask me to re-enter password

re-enter password:

Once the password is set, subsequently when i run other commands on the sadmin, It will prompt me to enter the password

sadmin enable password:

The password is not an argument to the command. It is passed to the prompt after running the command. So i am unable to achieve this by adding password as an argument to the command.

Community
  • 1
  • 1
  • 2
    What kind of EXE? A command line application, or a graphical windows application? How does it ask for the password? – Chris Shain Jun 22 '12 at 20:55
  • Welcome to this community. Please read up http://stackoverflow.com/questions/how-to-ask. – Ashish Gupta Jun 22 '12 at 20:59
  • Reading this over this doesn't look like the other question in that it involves interacting with the application after it starts. I don't think it deserves downvotes. – Jeff Aug 18 '14 at 21:25

2 Answers2

1

you can try

Process example= new Process();

            example.StartInfo.FileName   = "example.exe";
            example.StartInfo.Arguments = "arg";

            example.Start();
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
1

Have you tried using Process.StartInfo.Arguments? Something like this:

Process MyProcess = new Process();
MyProcess.StartInfo.FileName = "PathToExe";
MyProcess.StartInfo.Arguments = "YourArgsHere";
MyProcess.StartInfo.WorkingDirectory = "DesiredWorkingDir(Optional)";
MyProcess.Start();
CIGuy
  • 5,076
  • 28
  • 37