Solved

Running command lines from a console application in .net

Posted on 2004-10-26
167 Views
Last Modified: 2010-04-15
Hello
I am new to  writing console applications in .net.  I have written a application that reads in filenames and combines them into one.  That i have working properly
                  

now I need to encrypt that file using pgp command lines, I know the command lines
however I do i get the application to run those command lines before shutting down the application
0
Question by:aasaif00
    8 Comments
     

    Author Comment

    by:aasaif00
    sorry misprint above how do i get the application to run those command lines before shutting down the application
    0
     
    LVL 8

    Expert Comment

    by:Razzie_
    You can start pgp using

    System.Diagnostics.Process p = Process.Start(@"C:\pgp.exe", "command1 command2 command3");

    where C:\pgp.exe is your path to the pgp program and command1 to 3 are the command parameters you'd normally give them.

    HTH,

    Razzie
    0
     

    Author Comment

    by:aasaif00
    there are mutiple sequential commands i have to run

    pgp.exe

    pgp -e filename

    yes

    however i couldnot pass all those parameters into the function u showed me am i missing something
    0
     
    LVL 8

    Expert Comment

    by:Razzie_
    System.Diagnostics.Process p = Process.Start(@"C:\pgp.exe", "-e " + filename);

    where filename is the name of the variable (you could hardcode that name in the command of course "-e somefile" etc.
    0
     

    Author Comment

    by:aasaif00
    sorry im still confused because i need to add more parameters then that

    example on the first prompt i must type in the executible
    pgp

    next prompt i have to type in a command
    C:PGP> pgp -e filename

    the next prompt will ask me if im sure i want to encrypt this i type
    yes

    is there any way to program this if i already know all the answers
    0
     

    Author Comment

    by:aasaif00
    actually it also asks for the user id
    0
     
    LVL 18

    Expert Comment

    by:armoghan
    0
     
    LVL 18

    Accepted Solution

    by:
    When you get the process you can send keys to it as well
    see the following PAQ as well for sending keys to an appliaction
    http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20895124.html
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

     Java Android Coding Bundle

    Whether you're an Apple user or Android addict, learning to code for the Android platform is an extremely valuable, in-demand skill. It all starts with Java, the language behind the apps and games that make Android the top platform it is today.

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now