Shell problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • silas
    New Member
    • Apr 2010
    • 1

    Shell problems

    Hi!

    I had no expereince in coding a few months ago, and i didn't see the point either, thought it'd be rubbish! then when i had to study it for my collage course this year my god i took a liking to it, it passes the time and allows me to make stuff that are helpful for me and maybe others =)

    Anyways i figured i'd sign up to a forum so i can read post and find ideas for some projects, and i'm current stuck on one of my projects at the moment =)

    If i use the command in dos:

    Code:
    c:\program files\winrar\winrar.exe e "ffmpeg.7z" bin\ffmpeg.exe
    This will extract the file ffmpeg.exe located in the bin folder of the rar archive, works perfectly... then i tried to implement that into my project with this

    you should note i have the file being downloaded using webclient

    Code:
    webClient.DownloadFileAsync(new Uri("http://ffmpeg.arrozcru.org/autobuilds/ffmpeg-latest-mingw32-static.7z"), "ffmpeg.7z");
    this downloads the file directly to the built exe for the project

    Code:
    if (File.Exists("C://Program Files//WinRAR//WinRAR.exe"))
                 {
                     winrar = "C://Program Files//WinRAR//WinRAR.exe";
                     proc.EnableRaisingEvents = false;
                     proc.StartInfo.FileName = winrar;
                     proc.StartInfo.Arguments = "e ffmpeg.7z bin//ffmpeg.exe";
                     proc.Start();
                     label4.Text = "Extracting";
                     proc.WaitForExit();
                     label4.Text = null;
                     label3.Text = "FFMPEG Updated";
                 }
            else
                 {
                     MessageBox.Show("Winrar is either not installed or installed to a diffrent location... Please find it for me!"); 
                     openwin.Filter = "|winrar.exe";
                     openwin.ShowDialog();
                     proc.EnableRaisingEvents = false;
                     proc.StartInfo.FileName = openwin.FileName;
                     proc.StartInfo.Arguments = "e ffmpeg.7z bin//ffmpeg.exe";
                     proc.Start();
                     label4.Text = "Extracting";
                     proc.WaitForExit();
                     label4.Text = null;
                     label3.Text = "FFMPEG Updated";
                }
    Now in my eyes that should work, i can't see a fault yet it still does nothing, any ideas?!

    The project i'm making is a simple FFMPEG converter from whatever to an flv, i have a problem with that also =)

    Code:
     
            private void button4_Click(object sender, EventArgs e)
            {
                // converting ends prematurly
                // maybe add "no file input / output"
                // ****ing **** crap
                try
                {
                    proc.EnableRaisingEvents = false;
                    proc.StartInfo.FileName = "ffmpeg.exe";
                    proc.StartInfo.Arguments = "-y -i " + open.FileName + " -acodec libmp3lame -ar 22050 -f flv " + save.FileName;
                    proc.Start();
                }
                catch
                {
                    MessageBox.Show("There was an error converting that file!");
                }
            }
    Problem here is the conversion starts in a separate window, not too sure if i care about that though, but it ends a few seconds in with no errors or anything, as if system.diagnost ics is set to end the process if nothing happens after x amount of seconds

    Thanks in advance guys!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    It is only the \ that has to be escaped by making it \\
    Using the / you would only need a single \. Althought I am not sure if windows chokes on using different slash formats.
    Have you tried setting a breakpoint and stepping through it?

    You're also using "relative" pathnames for the output. It might not be extracting the files where you think.
    For texting purposes try something like: "e ffmpeg.7z c:\\bin\\ffmpeg .exe";
    (or some other absolute pathname)

    EDIT:
    For your second part: Yes it will open in a "seperate window". You're running a seperate process. If you really wanted to, you can redirect the standard IO (in/out/error) to your project and examine the output/etc to see what the program is saying.
    You can also tell it to NOT draw the dos-box-y window when running the process

    Comment

    Working...