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. CMD.exe help

CMD.exe help

Scheduled Pinned Locked Moved C#
helpquestion
18 Posts 4 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.
  • S Offline
    S Offline
    soloforce
    wrote on last edited by
    #1

    I’m trying to run the following command string from a GUI, everything works fine but I can minimize the command prompt or run it in hidden mode. Any way to do this? string stfamtv0001 = "/C" + ("\"\"C:\\Program Files\\ ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); private void data(string streamPath) { System.Diagnostics.Process ps; ps = new System.Diagnostics.Process(); ps.EnableRaisingEvents = false; System.Diagnostics.Process.Start("CMD.exe", streamPath); ps.Close(); } private void btnFOX_Click(object sender, EventArgs e) { data(stfamtv0001); }

    S 1 Reply Last reply
    0
    • S soloforce

      I’m trying to run the following command string from a GUI, everything works fine but I can minimize the command prompt or run it in hidden mode. Any way to do this? string stfamtv0001 = "/C" + ("\"\"C:\\Program Files\\ ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); private void data(string streamPath) { System.Diagnostics.Process ps; ps = new System.Diagnostics.Process(); ps.EnableRaisingEvents = false; System.Diagnostics.Process.Start("CMD.exe", streamPath); ps.Close(); } private void btnFOX_Click(object sender, EventArgs e) { data(stfamtv0001); }

      S Offline
      S Offline
      saurabh sahay
      wrote on last edited by
      #2

      You can run it in silent mode. ProcessStartInfo i = new ProcessStartInfo(); i.CreateNoWindow = true; i.UseShellExecute = false; i.RedirectStandardError = true; i.FileName = "file to execute"; i.Arguments = (@"arguments"); System.Diagnostics.Process proc = Process.Start(i);

      S 1 Reply Last reply
      0
      • S saurabh sahay

        You can run it in silent mode. ProcessStartInfo i = new ProcessStartInfo(); i.CreateNoWindow = true; i.UseShellExecute = false; i.RedirectStandardError = true; i.FileName = "file to execute"; i.Arguments = (@"arguments"); System.Diagnostics.Process proc = Process.Start(i);

        S Offline
        S Offline
        soloforce
        wrote on last edited by
        #3

        Can seem to get this to work, do you mind filling on the "file to execute" and the "arguments" so i have an example.

        S 1 Reply Last reply
        0
        • S soloforce

          Can seem to get this to work, do you mind filling on the "file to execute" and the "arguments" so i have an example.

          S Offline
          S Offline
          saurabh sahay
          wrote on last edited by
          #4

          If command to execute in shell is "FOP.exe -XML abc.xml - pdf abc.pdf" Then file to execute is FOP.exe and arguments are -XML abc.xml - pdf abc.pdf

          S 1 Reply Last reply
          0
          • S saurabh sahay

            If command to execute in shell is "FOP.exe -XML abc.xml - pdf abc.pdf" Then file to execute is FOP.exe and arguments are -XML abc.xml - pdf abc.pdf

            S Offline
            S Offline
            saurabh sahay
            wrote on last edited by
            #5

            Hope you get it now ?

            S 1 Reply Last reply
            0
            • S saurabh sahay

              Hope you get it now ?

              S Offline
              S Offline
              soloforce
              wrote on last edited by
              #6

              No my code still is not working? ProcessStartInfo ps = new ProcessStartInfo(); ps.CreateNoWindow = true; ps.UseShellExecute = false; ps.RedirectStandardError = true; ps.FileName = "cmd.exe"; ps.Arguments = (@"/C" + "\"\"C:\\Program Files\\ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --halfscreen --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); System.Diagnostics.Process proc = Process.Start(ps); Not sure why when its put into a click event nothing happens.

              L S 2 Replies Last reply
              0
              • S soloforce

                No my code still is not working? ProcessStartInfo ps = new ProcessStartInfo(); ps.CreateNoWindow = true; ps.UseShellExecute = false; ps.RedirectStandardError = true; ps.FileName = "cmd.exe"; ps.Arguments = (@"/C" + "\"\"C:\\Program Files\\ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --halfscreen --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); System.Diagnostics.Process proc = Process.Start(ps); Not sure why when its put into a click event nothing happens.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                step through the code and make a dummy string hold your Ps.Arguments property and see if it is correct as you would type it into the command prompt.

                Check out the CodeProject forum Guidelines[^]

                1 Reply Last reply
                0
                • S soloforce

                  No my code still is not working? ProcessStartInfo ps = new ProcessStartInfo(); ps.CreateNoWindow = true; ps.UseShellExecute = false; ps.RedirectStandardError = true; ps.FileName = "cmd.exe"; ps.Arguments = (@"/C" + "\"\"C:\\Program Files\\ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --halfscreen --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); System.Diagnostics.Process proc = Process.Start(ps); Not sure why when its put into a click event nothing happens.

                  S Offline
                  S Offline
                  saurabh sahay
                  wrote on last edited by
                  #8

                  You need not use cmd.exe as it the command shell which would automatically get invoked. your executable file here is /C" + "\"\"C:\\Program Files\\ThinTV\\PLINK.EXE and your arguments is appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=.0; vlc --halfscreen --key-vol-up 100 rtsp://stfamtv0001/streama\"\"" Please arrange it accordingly. Let me know if you still need some help.

                  S 1 Reply Last reply
                  0
                  • S saurabh sahay

                    You need not use cmd.exe as it the command shell which would automatically get invoked. your executable file here is /C" + "\"\"C:\\Program Files\\ThinTV\\PLINK.EXE and your arguments is appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=.0; vlc --halfscreen --key-vol-up 100 rtsp://stfamtv0001/streama\"\"" Please arrange it accordingly. Let me know if you still need some help.

                    S Offline
                    S Offline
                    soloforce
                    wrote on last edited by
                    #9

                    Ok I broke the code down and put it into a click event as follows ProcessStartInfo ps = new ProcessStartInfo(); ps.CreateNoWindow = true; ps.UseShellExecute = false; ps.RedirectStandardError = true; ps.FileName = "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); System.Diagnostics.Process proc = Process.Start(ps); Not sure but now its getting a Win32Excepetion was unhanded error.... on this line System.Diagnostics.Process proc = Process.Start(ps); The command string is perfect.... its really weird.

                    S 2 Replies Last reply
                    0
                    • S soloforce

                      Ok I broke the code down and put it into a click event as follows ProcessStartInfo ps = new ProcessStartInfo(); ps.CreateNoWindow = true; ps.UseShellExecute = false; ps.RedirectStandardError = true; ps.FileName = "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); System.Diagnostics.Process proc = Process.Start(ps); Not sure but now its getting a Win32Excepetion was unhanded error.... on this line System.Diagnostics.Process proc = Process.Start(ps); The command string is perfect.... its really weird.

                      S Offline
                      S Offline
                      saurabh sahay
                      wrote on last edited by
                      #10

                      "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; -----here what is "/C" ? To check the validity of the code. USe ps.FileName = "Notepad"; ps.Arguments = "abc.txt" Check whether notepad opens or not and then check your code accordingly.

                      S S 2 Replies Last reply
                      0
                      • S soloforce

                        Ok I broke the code down and put it into a click event as follows ProcessStartInfo ps = new ProcessStartInfo(); ps.CreateNoWindow = true; ps.UseShellExecute = false; ps.RedirectStandardError = true; ps.FileName = "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); System.Diagnostics.Process proc = Process.Start(ps); Not sure but now its getting a Win32Excepetion was unhanded error.... on this line System.Diagnostics.Process proc = Process.Start(ps); The command string is perfect.... its really weird.

                        S Offline
                        S Offline
                        saurabh sahay
                        wrote on last edited by
                        #11

                        Also do the following ps.FileName = "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); System.Console.WriteLine(ps.FileName + ps.Arguments); and see the string displayed on the console is the right command string for cmd.exe or not?

                        1 Reply Last reply
                        0
                        • S saurabh sahay

                          "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; -----here what is "/C" ? To check the validity of the code. USe ps.FileName = "Notepad"; ps.Arguments = "abc.txt" Check whether notepad opens or not and then check your code accordingly.

                          S Offline
                          S Offline
                          Skymir
                          wrote on last edited by
                          #12

                          /C is a command line switch for cmd.exe. I believe the filename string should be "C:\\Program Files\\RBS ThinTV\\PLINK.EXE"

                          The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.

                          S 1 Reply Last reply
                          0
                          • S Skymir

                            /C is a command line switch for cmd.exe. I believe the filename string should be "C:\\Program Files\\RBS ThinTV\\PLINK.EXE"

                            The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.

                            S Offline
                            S Offline
                            saurabh sahay
                            wrote on last edited by
                            #13

                            I guess you are correct..

                            1 Reply Last reply
                            0
                            • S saurabh sahay

                              "/C" + "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\""; -----here what is "/C" ? To check the validity of the code. USe ps.FileName = "Notepad"; ps.Arguments = "abc.txt" Check whether notepad opens or not and then check your code accordingly.

                              S Offline
                              S Offline
                              soloforce
                              wrote on last edited by
                              #14

                              Ok I was able to verify that this test with notepad worked great so I think the error is in my arguments. The original argument that works in a command prompt is this. "/C" + ("\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); So at this point since we are not using a command prompt the "/C" is nulled which leaves us with "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); Breaking this command string down we have ps.FileName = "C:\\Program Files\\RBS ThinTV\\PLINK.EXE"; and ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); The trick now i believe is int he syntax.

                              S S 2 Replies Last reply
                              0
                              • S soloforce

                                Ok I was able to verify that this test with notepad worked great so I think the error is in my arguments. The original argument that works in a command prompt is this. "/C" + ("\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); So at this point since we are not using a command prompt the "/C" is nulled which leaves us with "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); Breaking this command string down we have ps.FileName = "C:\\Program Files\\RBS ThinTV\\PLINK.EXE"; and ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); The trick now i believe is int he syntax.

                                S Offline
                                S Offline
                                saurabh sahay
                                wrote on last edited by
                                #15

                                what do u do soloforce?

                                S 1 Reply Last reply
                                0
                                • S saurabh sahay

                                  what do u do soloforce?

                                  S Offline
                                  S Offline
                                  soloforce
                                  wrote on last edited by
                                  #16

                                  Im a network engineer for a small company, but I enjoy programing keeps my mind sharp. I dont have much expereince in programing but I sure like it. :-D

                                  S 1 Reply Last reply
                                  0
                                  • S soloforce

                                    Im a network engineer for a small company, but I enjoy programing keeps my mind sharp. I dont have much expereince in programing but I sure like it. :-D

                                    S Offline
                                    S Offline
                                    saurabh sahay
                                    wrote on last edited by
                                    #17

                                    cool!!..good to know about you :)

                                    1 Reply Last reply
                                    0
                                    • S soloforce

                                      Ok I was able to verify that this test with notepad worked great so I think the error is in my arguments. The original argument that works in a command prompt is this. "/C" + ("\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); So at this point since we are not using a command prompt the "/C" is nulled which leaves us with "\"\"C:\\Program Files\\RBS ThinTV\\PLINK.EXE\"" + " " + "appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --key-vol-up 100 rtsp://stfamtv0001/streama\"\""); Breaking this command string down we have ps.FileName = "C:\\Program Files\\RBS ThinTV\\PLINK.EXE"; and ps.Arguments = (@"appliance@%ThinConnectedFrom%" + " " + "-pw appliance" + " " + "\"killall -q vlc; export DISPLAY=:0.0; vlc --video-on-top --key-vol-up 100 rtsp://stfamtv0002/streama\"\""); The trick now i believe is int he syntax.

                                      S Offline
                                      S Offline
                                      soloforce
                                      wrote on last edited by
                                      #18

                                      Is there anyway i can really test the syntax to make sure is all correct?

                                      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