Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How will I pass argument to Process

How will I pass argument to Process

Scheduled Pinned Locked Moved C#
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naveed727
    wrote on last edited by
    #1

    Hi, I am using the following code Process pr = new Process(); pr.StartInfo.FileName = "SCHTASKS.exe"; // pr.StartInfo.CreateNoWindow = true; // pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Arguments = "/Delete " + ScheduleName; when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully. I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments If any one can help me. Regards

    S L 2 Replies Last reply
    0
    • N Naveed727

      Hi, I am using the following code Process pr = new Process(); pr.StartInfo.FileName = "SCHTASKS.exe"; // pr.StartInfo.CreateNoWindow = true; // pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Arguments = "/Delete " + ScheduleName; when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully. I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments If any one can help me. Regards

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Naveed727 wrote:

      a confirmation will appear

      There is no reliable way to do that, unless the program you are starting is rewritten to accept another command line parameter to suppress prompts. You could try writing to the process's input stream - check out Process.StandardInput[^]

      Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

      1 Reply Last reply
      0
      • N Naveed727

        Hi, I am using the following code Process pr = new Process(); pr.StartInfo.FileName = "SCHTASKS.exe"; // pr.StartInfo.CreateNoWindow = true; // pr.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; pr.StartInfo.Arguments = "/Delete " + ScheduleName; when I pass the delete argument in command prompt a confirmation will appear. After pressing "y" it the schedule is deleted successfully. I want to pass "y" as arguments but don't know how because I am already passing delete command in arguments If any one can help me. Regards

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, I am assuming SCHTASKS is a regular console application, that produces some output (a prompt) in the console or DOS window, and takes some input from there as well. The easy solution, if provided, is by passing another switch; try "SCHTASKS -h" to see its help. If no extra switches are available, you should be able to do it with standard stream redirection; have a look at the Process class, StandardInput/StandardOutput properties, and OutputDataReceived events. You probably need to redirect the output (so you can wait for the confirmation prompt to arrive), AND redirect the input stream, so you can writeline "Y" to it. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups