0

I'm trying to run SoX command using ProcessStart but it's giving me an error with Access denied, i've made sure all admin access are in place not sure what else could be causing this error?

            var startInfo = new ProcessStartInfo();
            startInfo.FileName = @"C:\Data\sox1441";
            startInfo.Verb = "runas";
            startInfo.Arguments = ("sox -c 2 -b 24 -r 48000 --buffer 8000 -t waveaudio -d apple.wav trim 0 3");
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow = false;                
            startInfo.WorkingDirectory = @"C:\Data\";                       
            using (Process soxProc = Process.Start(startInfo))               
            {
                soxProc.WaitForExit();
            }
sameer
  • 9
  • 2
  • can you manually run the command? also, run your exe as admin, does it work? – urlreader May 18 '20 at 20:39
  • Is the executable you're trying to run `C:\Data\sox1441\sox`? At the moment, you're trying to run `C:\Data\sox1441`, and if that is a directory, you will get an access-denied error. – Luke Woodward May 18 '20 at 20:40
  • Correct it did fix by placing the sox.exe but my next issue is startInfo.Arguments, not sure if the syntax is correct but it does not seem to execute as i should be getting a file recording which didn't happen. BTW, the argument does work when i manually try in cmd in admin mode. – sameer May 18 '20 at 21:03
  • Firstly, did you amend the arguments to remove `sox` from the start? Otherwise you're basically running `C:\Data\sox1441\sox.exe sox -c 2 -b ...`. Also, is the executable writing anything to standard output or standard error? See [this question](https://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output) for an example of how to read such output. – Luke Woodward May 19 '20 at 20:48

0 Answers0