Search Results

Search found 97 results on 4 pages for 'processstartinfo'.

Page 1/4 | 1 2 3 4  | Next Page >

  • Start a process as LocalSystem using ProcessStartInfo

    - by auhorn
    I am trying to start a process as the LocalSystem account using this code ProcessStartInfo _startInfo = new ProcessStartInfo(commandName); _startInfo.UseShellExecute = false; _startInfo.UserName = @"NT AUTHORITY\SYSTEM"; _startInfo.CreateNoWindow = true; _startInfo.Arguments = argument; _startInfo.RedirectStandardOutput = true; using (Process _p = Process.Start(_startInfo)) { _retVal = _p.StandardOutput.ReadToEnd(); _p.WaitForExit(); } But I am getting always the same error message saying "Logon failure: unknown user name or bad password". The user calling the function is a local admin and should be able to start a process with local system privilege. I also tried different combination but no luck. I would appreciate any help. Thanks

    Read the article

  • Setting ProcessStartInfo.WorkingDirectory to an UNC Path

    - by TJOHN
    I have a utility that I have written in VB.net that runs as a scheduled tasks. It internally calls another executable and it has to access a mapped drive. Apparently windows has issues with scheduled tasks accessing mapped drives when the user is not logged on, even when the authentication credentials are supplied to the task itself. Ok, fine. To get around this I just passed my application the UNC path. process.StartInfo.FileName = 'name of executable' process.StartInfo.WorkingDirectory = '\\unc path\' process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden process.StartInfo.Arguments = 'arguments to executable' process.Start() This is the same implementation I used with the mapped drive, however using the UNC path, the process is not behaving as if the UNC path is the working directory. Are there any known issues setting ProcessStartInfo.WorkingDirectory to an UNC path? If not, what am I doing wrong?

    Read the article

  • Starting CLI application programmatically does not work depending on arguments

    - by Daniel Beck
    I try to start plink.exe (PuTTY Link, the command line utility/version of PuTTY) from a C# application to establish an SSH reverse tunnel, but it does no longer work as soon as I pass the correct parameters. What does that mean? The following works as expected: it opens a command line window, displays that I forgot to pass the password for the -pw argument quits, and shows the prompt. I know it got the arguments, since it specifically requests the one thing I did not provide. Uri uri = omitted; ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd"; info.Arguments = "/k \"C:\\Program Files (x86)\\PuTTY\\plink.exe\" -R 3389:" + uri.Host + ":" + uri.Port + " -N -l username -pw"; // TODO pwd Process p = Process.Start(info); I tried the same think with calling plink.exe directly instead of cmd.exe /k, but the window closes immediately, which is unfortunate for bug-hunting. BUT when I pass a password in the arguments, plink.exe displays the program help (showing available parameters) and quits: Uri uri = omitted; ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd"; info.Arguments = "/k \"C:\\Program Files (x86)\\PuTTY\\plink.exe\" -R 3389:" + uri.Host + ":" + uri.Port + " -N -l username -pw secretpassword"; Process p = Process.Start(info); No indication of missing parameters. Both the cmd /k and plink.exe variants do not work (the latter closes immediately, so no information regarding different behaviour). When I launch the application from the Windows 7 Start Menu launcher with the identical parameters, it opens a cmd.exe window and establishes the connection as requested. What's wrong? Is there a way plink.exe notices it's not running in a real shell? If yes, how can I circumvent it, like the Start Menu "prompt" does? I hope this question is right on SO, since it, though specifically for a single application, revolves around launching it successfully programmatically.

    Read the article

  • Starting Firefox using Process.Start: Firefox not starting when you set Usename and Password

    - by Mohammadreza
    Hi there. When I try to start Firefox using Process.Start and ProcessStartInfo (.NET) everything seems to work fine. But when I specify a username and password of another account (a member of Users), nothing seems to happen. The same code works fine with Calc.exe or IE. This is weird. Any ideas? Here is the code: System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.ProcessStartInfo(); pInfo.CreateNoWindow = false; pInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; pInfo.WorkingDirectory = "{WorkingDirectory}"; pInfo.Arguments = "{CommandLineArgs}"; pInfo.FileName = "{ExecutableAddress}"; pInfo.ErrorDialog = true; pInfo.UseShellExecute = false; pInfo.UserName = "{LimitedAccountUserName}"; pInfo.Password = "{SecureLimitedAccountPassword}"; System.Diagnostics.Process.Start(pInfo); Thanks everyone.

    Read the article

  • An Interactive Console I/O Wrapper/Interceptor in C# - What is the issue?

    - by amazedsaint
    I was trying to put together an interactive Console interceptor/wrapper in C# over the weekend, by re-mixing few code samples I've found in SO and other sites. With what I've as of now, I'm unable to read back from the console reliably. Any quick pointers? public class ConsoleInterceptor { Process _interProc; public event Action<string> OutputReceivedEvent; public ConsoleInterceptor() { _interProc = new Process(); _interProc.StartInfo = new ProcessStartInfo("cmd"); InitializeInterpreter(); } public ConsoleInterceptor(string command) { _interProc = new Process(); _interProc.StartInfo = new ProcessStartInfo(command); InitializeInterpreter(); } public Process InterProc { get { return _interProc; } } private void InitializeInterpreter() { InterProc.StartInfo.RedirectStandardInput = true; InterProc.StartInfo.RedirectStandardOutput = true; InterProc.StartInfo.RedirectStandardError = true; InterProc.StartInfo.CreateNoWindow = true; InterProc.StartInfo.UseShellExecute = false; InterProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; bool started = InterProc.Start(); Redirect(InterProc.StandardOutput); Redirect(InterProc.StandardError); } private void Redirect(StreamReader input) { new Thread((a) => { var buffer = new char[1]; while (true) { if (input.Read(buffer, 0, 1) > 0) OutputReceived(new string(buffer)); }; }).Start(); } private void OutputReceived(string text) { if (OutputReceivedEvent != null) OutputReceivedEvent(text); } public void Input(string input) { InterProc.StandardInput.WriteLine(input); InterProc.StandardInput.Flush(); } }

    Read the article

  • Starting a process synchronously, and "streaming" the output

    - by Benjol
    I'm looking at trying to start a process from F#, wait till it's finished, but also read it's output progressively. Is this the right/best way to do it? (In my case I'm trying to execute git commands, but that is tangential to the question) let gitexecute (logger:string->unit) cmd = let procStartInfo = new ProcessStartInfo(@"C:\Program Files\Git\bin\git.exe", cmd) // Redirect to the Process.StandardOutput StreamReader. procStartInfo.RedirectStandardOutput <- true procStartInfo.UseShellExecute <- false; // Do not create the black window. procStartInfo.CreateNoWindow <- true; // Create a process, assign its ProcessStartInfo and start it let proc = new Process(); proc.StartInfo <- procStartInfo; proc.Start() |> ignore // Get the output into a string while not proc.StandardOutput.EndOfStream do proc.StandardOutput.ReadLine() |> logger What I don't understand is how the proc.Start() can return a boolean and also be asynchronous enough for me to get the output out of the while progressively. Unfortunately, I don't currently have a large enough repository - or slow enough machine, to be able to tell what order things are happening in...

    Read the article

  • Whats the difference between Process and ProcessStartInfo in C#?

    - by JimDel
    Whats the difference between Process and ProcessStartInfo? Ive used both to launch external programs but there has to be a reason there are two ways to do it. Here are two examples. Process notePad = new Process(); notePad.StartInfo.FileName = "notepad.exe"; notePad.StartInfo.Arguments = "ProcessStart.cs"; notePad.Start(); and ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "notepad.exe"; startInfo.Arguments = " ProcessStart.cs "; Process.Start(startInfo) Thanks

    Read the article

  • Win32Exception: The directory name is invalid

    - by Mohammadreza
    I'm trying to run a process as a different user that has Administrator privilege in 2 different computers running Vista and their UAC enabled but in one of them I get a Win32Exception that says "The directory name is invalid" Can anyone tell me what is wrong with my code? var myFile = "D:\\SomeFolder\\MyExecutable.exe"; var workingFolder = "D:\\SomeFolder"; var pInfo = new System.Diagnostics.ProcessStartInfo(); pInfo.FileName = myFile; pInfo.WorkingDirectory = workingFolder; pInfo.Arguments = myArgs; pInfo.LoadUserProfile = true; pInfo.UseShellExecute = false; pInfo.UserName = {UserAccount}; pInfo.Password = {SecureStringPassword}; pInfo.Domain = "."; System.Diagnostics.Process.Start(pInfo); UPDATE The application that executes the above code has requireAdministrator execution level. I even set the working folder to "Path.GetDirectoryName(myFile)" and "New System.IO.FileInfo(myFile).DirectoryName"

    Read the article

  • How can I pass more than one command line argument via c#

    - by user293392
    I need to pass more than one command line argument via c# for a process called handle.exe: http://www.google.com.mt/search?sourceid=chrome&ie=UTF-8&q=handle.exe First, I need to run the executable file via ADMINISTRATOR permissions. This post has helped me achieve just that: http://stackoverflow.com/questions/667381/programatically-run-cmd-exe-as-adminstrator-in-vista-c But then comes the next problem of calling the actual line arguments such as "-p explore" How can I specify the command line arguments together, or maybe consecutively? Current code is as follows: Process p = new Process(); ProcessStartInfo processStartInfo = new ProcessStartInfo("filePath"); processStartInfo.CreateNoWindow = true; processStartInfo.UseShellExecute = false; processStartInfo.RedirectStandardOutput = true; processStartInfo.RedirectStandardInput = true; processStartInfo.Verb = "runas"; processStartInfo.Arguments = "/env /user:" + "Administrator" + " cmd"; p.StartInfo = processStartInfo; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); Console.WriteLine(output); Thanks

    Read the article

  • C# - Launch Invisible Process (CreateNoWindow & WindowStyle not working?)

    - by Chad
    I have 2 programs (.exe) which I've created in .NET. We'll call them the Master and the Worker. The Master starts 1 or more Workers. The Worker will not be interacted with by the user, but it is a WinForms app that receives commands and runs WinForms components based on the commands it receives from the Master. I want the Worker app to run completely hidden (except showing up in the Task Manager of course). I thought that I could accomplish this with the StartInfo.CreateNoWindow and StartInfo.WindowStyle properties, but I still see the Client.exe window and components in the form. However, it doesn't show up in the taskbar. Process process = new Process { EnableRaisingEvents = true, StartInfo = { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden FileName = "Client.exe", UseShellExecute = false, ErrorDialog = false, } }; What do I need to do to let Client.exe run, but not show up?

    Read the article

  • Executing a Batch file from remote Ax client on an AOS server

    - by Anisha
    Is it possible to execute a batch file on an AOS server from a remote AX client? Answer is yes, provided you have necessary permission for this execution on the server. Please create a batch file on your AOS server. Some thing as below for creating a directory on the server.    Insert a command something like this in a .BAT file (batch file) and place any were on the server.   Mkdir “c:\test”      Copy the following code into your server static method of your class and call this piece of code from a button click on Ax form. Please execute this button click from a remote AX client and see the result . This should execute the batch file on the server and should create a directory called ‘test’ on the root directoryof the server.     server static void AOS_batch_file_create() { boolean b; System.Diagnostics.Process process; System.Diagnostics.ProcessStartInfo processStartInfo; ; b = Global::isRunningOnServer(); infolog.add(0, int2str(b)); new InteropPermission(InteropKind::ClrInterop).assert(); process = new System.Diagnostics.Process(); processStartInfo = new System.Diagnostics.ProcessStartInfo(); processStartInfo.set_FileName("C:\\create_dir.bat"); // batch file path on the AOS server process.set_StartInfo(processStartInfo); process.Start(); //process.Refresh(); //process.Close(); //process.WaitForExit(); info("Finished"); }

    Read the article

  • Copy New Files Only in .NET

    - by psheriff
    Recently I had a client that had a need to copy files from one folder to another. However, there was a process that was running that would dump new files into the original folder every minute or so. So, we needed to be able to copy over all the files one time, then also be able to go back a little later and grab just the new files. After looking into the System.IO namespace, none of the classes within here met my needs exactly. Of course I could build it out of the various File and Directory classes, but then I remembered back to my old DOS days (yes, I am that old!). The XCopy command in DOS (or the command prompt for you pure Windows people) is very powerful. One of the options you can pass to this command is to grab only newer files when copying from one folder to another. So instead of writing a ton of code I decided to simply call the XCopy command using the Process class in .NET. The command I needed to run at the command prompt looked like this: XCopy C:\Original\*.* D:\Backup\*.* /q /d /y What this command does is to copy all files from the Original folder on the C drive to the Backup folder on the D drive. The /q option says to do it quitely without repeating all the file names as it copies them. The /d option says to get any newer files it finds in the Original folder that are not in the Backup folder, or any files that have a newer date/time stamp. The /y option will automatically overwrite any existing files without prompting the user to press the "Y" key to overwrite the file. To translate this into code that we can call from our .NET programs, you can write the CopyFiles method presented below. C# using System.Diagnostics public void CopyFiles(string source, string destination){  ProcessStartInfo si = new ProcessStartInfo();  string args = @"{0}\*.* {1}\*.* /q /d /y";   args = string.Format(args, source, destination);   si.FileName = "xcopy";  si.Arguments = args;  Process.Start(si);} VB.NET Imports System.Diagnostics Public Sub CopyFiles(source As String, destination As String)  Dim si As New ProcessStartInfo()  Dim args As String = "{0}\*.* {1}\*.* /q /d /y"   args = String.Format(args, source, destination)   si.FileName = "xcopy"  si.Arguments = args  Process.Start(si)End Sub The CopyFiles method first creates a ProcessStartInfo object. This object is where you fill in name of the command you wish to run and also the arguments that you wish to pass to the command. I created a string with the arguments then filled in the source and destination folders using the string.Format() method. Finally you call the Start method of the Process class passing in the ProcessStartInfo object. That's all there is to calling any command in the operating system. Very simple, and much less code than it would have taken had I coded it using the various File and Directory classes. Good Luck with your Coding,Paul Sheriff ** SPECIAL OFFER FOR MY BLOG READERS **Visit http://www.pdsa.com/Event/Blog for a free video on Silverlight entitled Silverlight XAML for the Complete Novice - Part 1.  

    Read the article

  • How to determine Windows Java installation location

    - by Lance May
    I'm trying to dynamically run a .jar from a C# assembly (using Process.Start(info)). Now, from a console application I am able to just run: ProcessStartInfo info = new ProcessStartInfo("java", "-jar somerandom.jar"); In an assembly, however, I keep getting a Win32Exception of "The system cannot find the file specified" and have to change the line to the full path of Java like so: ProcessStartInfo info = new ProcessStartInfo("C:\\Program Files\\Java\\jre6\\bin\\java.exe", "-jar somerandom.jar"); This obviously won't do. I need a way to dynamically (but declaratively) determine the installed location of Java. I started thinking of looking to the registry, but when I go there I noticed that there were specific keys for the versions and that they could not even be guaranteed to be numeric (e.g. "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6" and "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_20"). What would be the most reliable "long-haul" solution to finding the most up-to-date java.exe path from a C# application? Thanks much in advance.

    Read the article

  • About redirected stdout in System.Diagnostics.Process

    - by sforester
    I've been recently working on a program that convert flac files to mp3 in C# using flac.exe and lame.exe, here are the code that do the job: ProcessStartInfo piFlac = new ProcessStartInfo( "flac.exe" ); piFlac.CreateNoWindow = true; piFlac.UseShellExecute = false; piFlac.RedirectStandardOutput = true; piFlac.Arguments = string.Format( flacParam, SourceFile ); ProcessStartInfo piLame = new ProcessStartInfo( "lame.exe" ); piLame.CreateNoWindow = true; piLame.UseShellExecute = false; piLame.RedirectStandardInput = true; piLame.RedirectStandardOutput = true; piLame.Arguments = string.Format( lameParam, QualitySetting, ExtractTag( SourceFile ) ); Process flacp = null, lamep = null; byte[] buffer = BufferPool.RequestBuffer(); flacp = Process.Start( piFlac ); lamep = new Process(); lamep.StartInfo = piLame; lamep.OutputDataReceived += new DataReceivedEventHandler( this.ReadStdout ); lamep.Start(); lamep.BeginOutputReadLine(); int count = flacp.StandardOutput.BaseStream.Read( buffer, 0, buffer.Length ); while ( count != 0 ) { lamep.StandardInput.BaseStream.Write( buffer, 0, count ); count = flacp.StandardOutput.BaseStream.Read( buffer, 0, buffer.Length ); } Here I set the command line parameters to tell lame.exe to write its output to stdout, and make use of the Process.OutPutDataRecerved event to gather the output data, which is mostly binary data, but the DataReceivedEventArgs.Data is of type "string" and I have to convert it to byte[] before put it to cache, I think this is ugly and I tried this approach but the result is incorrect. Is there any way that I can read the raw redirected stdout stream, either synchronously or asynchronously, bypassing the OutputDataReceived event? PS: the reason why I don't use lame to write to disk directly is that I'm trying to convert several files in parallel, and direct writing to disk will cause severe fragmentation. Thanks a lot!

    Read the article

  • User switching without logging off

    - by mrh1967
    We need to switch users without logging off so we can remotely administrate a PC running with a limited user that will disconnect from the VPN if the user logs off. I've got this working by killing the explorer process and then running explorer.exe with the administrator user credentials as the following code shows: private void btnOk_Click(object sender, EventArgs e) { IntPtr tokenHandle = new IntPtr(0); if (LogonUser("administrator", Environment.UserDomainName, txtPassword.Text, 3, 0, ref tokenHandle)) { ProcessStartInfo psi = new ProcessStartInfo(@"C:\Windows\explorer.exe"); psi.UserName = "administrator"; char[] pword = txtPassword.Text.ToCharArray(); psi.Password = new System.Security.SecureString(); foreach (char c in pword) { psi.Password.AppendChar(c); } psi.UseShellExecute = false; psi.LoadUserProfile = true; restartExplorer(psi); this.Close(); } else { MessageBox.Show("Wrong password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } private void restartExplorer(ProcessStartInfo psi) { Process[] procs = System.Diagnostics.Process.GetProcesses(); foreach (Process p in procs) { if (p.ProcessName == "explorer") { p.Kill(); break; } } System.Diagnostics.Process.Start(psi); } [DllImport("advapi32.dll", SetLastError = true)] public extern static bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); This code and similar code that does the same but makes the ProcessStartInfo for the limited user works perfectly and allows changing between the limited and administrator accounts without disconnecting the VPN but it has one problem - If we use this to change to the administrator user, make some changes to the system, then change back to the limited user all works ok until the limited user logs off when a blank desktop is displayed until CTRL-ALT-DEL is pressed and the user is logged off again. Because we block CTRL-ALT-DEL the PC effectively hangs until it is powered off. Does anyone know how to stop this from happening so we can change users without the PC hanging when they log off?

    Read the article

  • svnlook always returns an error and no output

    - by Pierre-Alain Vigeant
    I'm running this small C# test program launched from a pre-commit batch file private static int Test(string[] args) { var processStartInfo = new ProcessStartInfo { FileName = "svnlook.exe", UseShellExecute = false, ErrorDialog = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true, Arguments = "help" }; using (var svnlook = Process.Start(processStartInfo)) { string output = svnlook.StandardOutput.ReadToEnd(); svnlook.WaitForExit(); Console.Error.WriteLine("svnlook exited with error 0x{0}.", svnlook.ExitCode.ToString("X")); Console.Error.WriteLine("Current output is: {0}", string.IsNullOrEmpty(output) ? "empty" : output); return 1; } } I am deliberately calling svnlook help and forcing an error so I can see what is going on when committing. When this program run, SVN displays svnlook exited with error 0xC0000135. Current output is: empty I looked up the error 0xC0000135 and it mean App failed to initialize properly although it wasn't specific to svnhook. Why is svnlook help not returning anything? Does it fail when executed through another process?

    Read the article

  • pass custom environment variables to System.Diagnostics.Process

    - by Mike Ruhlin
    I'm working on an app that invokes external processes like so: ProcessStartInfo startInfo = new ProcessStartInfo(PathToExecutable, Arguments){ ErrorDialog = false, RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true, WorkingDirectory = WorkingDirectory }; using (Process process = new Process()) { process.StartInfo = startInfo; process.Start(); process.BeginErrorReadLine(); process.BeginOutputReadLine(); process.WaitForExit(); return process.ExitCode; } One of the processes I'm calling depends on an environment variable that I'd rather not require my users to set. Is there any way to modify the environment variables that get sent to the external process? Ideally I'd be able to make them visible only to the process that's running, but if I have to programmatically set them system-wide, I'll settle for that (but, would UAC force me to run as administrator to do that?) ProcessStartInfo.EnvironmentVariables is read only, so a lot of help that is...

    Read the article

  • C# output of running command prompt

    - by Kaushal Singh
    In this following code whenever I send any command like dir or anything this function get stuck in while loop... I want the output of the command prompt each time I send it command to execute without closing the process after the execution of command. public void shell(String cmd) { ProcessStartInfo PSI = new ProcessStartInfo(); PSI.FileName = "c:\\windows\\system32\\cmd.exe"; PSI.RedirectStandardInput = true; PSI.RedirectStandardOutput = true; PSI.RedirectStandardError = true; PSI.UseShellExecute = false; Process p = Process.Start(PSI); StreamWriter CSW = p.StandardInput; StreamReader CSR = p.StandardOutput; CSW.WriteLine(cmd); CSW.Flush(); while(!(CSR.EndOfStream)) { Console.WriteLine(CSR.ReadLine()); } CSR.Close(); }

    Read the article

  • Running DOS command through C# just opens blank cmd window

    - by Mohit Deshpande
    I was trying to execute a command through C#, but when I run the following code, a blank cmd window just opens up. The code: string command = string.Format(@"adb install C:\Users\Mohit\Programming\Android_Workspace\{0}\bin\{0}.apk", appName); ProcessStartInfo cmdsi = new ProcessStartInfo("cmd.exe"); cmdsi.Arguments = command; Process cmd = Process.Start(cmdsi); What could be wrong? I am sure the syntax is right.

    Read the article

  • System.Diagnostics.Process to run processes, send parameters and get output

    - by Lily
    Hi, I am trying to call a process using System.Diagnostics.Process, send it a parameter, just for the sake of trying it out i am sending "-h" which should generate a list of help options and I need the output. So far I have tried, ProcessStartInfo startInfo = new ProcessStartInfo("C:\\agfl\\agfl.exe"); startInfo.WindowStyle = ProcessWindowStyle.Normal; startInfo.CreateNoWindow = false; startInfo.Arguments = "-h"; Process.Start(startInfo); Any help please? Thanks :)

    Read the article

  • redirect any results in command prompt to richtext box

    - by Kasun
    Hi all, I need to redirect any results in command prompt to richtext box. Can any one provide me the necessary steps. This is how i start my command prompt. ProcessStartInfo psi = new ProcessStartInfo { FileName = "cmd", Arguments = @"/k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat""", }; Process.Start(psi);

    Read the article

  • xcopy file, suppress &ldquo;Does xxx specify a file name&hellip;&rdquo; message

    - by MarkPearl
    Today we had an interesting problem with file copying. We wanted to use xcopy to copy a file from one location to another and rename the copied file but do this impersonating another user. Getting the impersonation to work was fairly simple, however we then had the challenge of getting xcopy to work. The problem was that xcopy kept prompting us with a prompt similar to the following… Does file.xxx specify a file name or directory name on the target (F = file, D = directory)? At which point we needed to press ‘Y’. This seems to be a fairly common challenge with xcopy, as illustrated by the following stack overflow link… One of the solutions was to do the following… echo f | xcopy /f /y srcfile destfile This is fine if you are running from the command prompt, but if you are triggering this from c# how could we daisy chain a bunch of commands…. The solution was fairly simple, we eventually ended up with the following method… public void Copy(string initialFile, string targetFile) { string xcopyExe = @"C:\windows\system32\xcopy.exe"; string cmdExe = @"C:\windows\system32\cmd.exe"; ProcessStartInfo p = new ProcessStartInfo(); p.FileName = cmdExe; p.Arguments = string.Format(@"/c echo f | {2} {0} {1} /Y", initialFile, targetFile, xcopyExe); Process.Start(p); } Where we wrapped the commands we wanted to chain as arguments and instead of calling xcopy directly, we called cmd.exe passing xcopy as an argument.

    Read the article

  • Convert MP3 to AAC,FLAC to AAC (.NET/C#) FREE :)

    - by PearlFactory
    So I was tasked with looking at converting 10 million tracks from mp3 320k to AAC and also Converting from mp3 320k to mp3 128k After a bit of hunting around the tool you need to use is FFMPEG Download x64 WindowsAlso for the best results get the Nero AACEncoder Download Now the command line STEP 1(From Flac)ffmpeg -i input.flac -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of output.m4aor (From mp3)ffmpeg -i input.mp3 -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of output.m4aNow the output.m4a is a intermediate state that we now put a ACC wrapper on via FFMpeg STEP 2ffmpeg -i output.m4a -vn -acodec copy final.aacDone :) There are a couple of options with the FFMPEG library as in we can look at importing the librarys and manipulation the API for the direct result FFMPEG has this support. You can get the relevant librarys from HereThey even have the source if you are that keen :-)In this case I am going to wrap the command lines into c# external process threads.( For the app that i am building to convert the 10 million tracks there is a complex multithreaded app to support this novel code )//Arrange Metadata about Call Process myProcess = new Process();ProcessStartInfo p = new ProcessStartInfo();string sArgs = string.format(" -i {0} -f wav - | neroAacEnc -ignorelength -q 0.5 -if - -of {1}",inputfile,outputfil) ; p.FileName = "ffmpeg.exe" ; p.CreateNoWindow = true; p.RedirectStandardOutput = true; //p.WindowStyle = ProcessWindowStyle.Normal p.UseShellExecute = false;//Execute p.Arguments = sArgs; myProcess.StartInfo = p; myProcess.Start(); myProcess.WaitForExit();//Write details about call  myProcess.StandardOutput.ReadToEnd();Now in this case we would execute a 2nd call using the same code but with different sArgs to put the AAC wrapper on the m4a file. Thats it. So if you need to do some conversions of any kind for you ASP.net sites/apps this is a great start and super fast.. With conversion times of around 2-3 seconds all of this can be done on the fly:-)Justin Oehlmannref : StackOverflow.com

    Read the article

  • No application is associated with the specified file exception

    - by baron
    UnhandledException: System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start(String fileName) Hi everyone, I am getting the following exception on one machine I am testing on when trying to use Process.Start to open a .csv file. I think this is happening because no file association has been set for .csv files on this box. So how would you avoid this situation? Force the Process.Start to open in Notepad? - Ideally it should be opened in excel, but what do you do if excel then doesn't exist on that computer? Thanks

    Read the article

  • Printing PDFs Server-side using Acrobat Reader from ASP.NET

    - by Chris Roberts
    Hi, I have been presented with a problem which requires me to print PDF files from a server as part of an ASP.NET web service. The problem is further complicated by the fact that the PDF files I have to print can ONLY be printed using Adobe Reader (they were created using Adobe LiveCycle and have some strange protection in them). This piece of code seems to do the trick in the Visual Studio development web server, but doesn't do anything when the site's running in IIS. I'm assuming this is probably some sort of permissions issue!? I know this is a FAR from ideal thing to be trying to do, but I haven't really got much choice! Any ideas would be greatly appreciated! Dim starter As ProcessStartInfo Dim Prc As Process ' Pass File Path And Arguments starter = New ProcessStartInfo("c:\program files\...\AcroRd32.exe", "/t ""test.pdf"" ""Printer""") starter.CreateNoWindow = True starter.RedirectStandardOutput = True starter.UseShellExecute = False ' Start Adobe Process Prc = New Process() Prc.StartInfo = starter Prc.Start()

    Read the article

1 2 3 4  | Next Page >