Search Results

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

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

  • alternatives to System.Diagnostics.Process.Start when command is too long

    - by Frank Schwieterman
    I have some code which is generating a rather long command that is being sent to System.Diagnostics.Process.Start(). The call fails with a Win32Exception, message "The filename or extension is too long". The path to the program itself is not very long, but the parameters passed in are quite long. I am calling the version where an instance of ProcessStartInfo is passed as the parameter, and in this case its the ProcessStartInfo.Arguments .Field that is very long. (other parameters: CreateNoWindow = true, UseShellExecute = false, RedirectStandardError = true). It looks like the exception is coming from a call to win32 function CreateProcess. Does anyone have an idea of another way to start the process?

    Read the article

  • Is there any explorer.exe problem in windows 7 ?

    - by sml
    s += "<p style=\"text-align: left;\"><a href=\"javascript:window.print()\">PRINT</a></p>"; System.IO.File.WriteAllText(@"CheckForm.html", s); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = "explorer.exe"; startInfo.Arguments = "CheckForm.html"; System.Diagnostics.Process.Start(startInfo); I'm having a trouble when I tried to open my c# windows application in windows 7 otherwise there is no problem. I couldn't open explorer.exe in Windows 7 with above code. Any suggestions?

    Read the article

  • Can't use ProcessWindowStyle.Minimized to start Firefox instance minimized?

    - by Rob3C
    I'm having trouble using Process.Start with Firefox. I want to start a new instance of Firefox in a minimized window. The following works fine with Internet Explorer, notepad, etc.: ProcessStartInfo p = new ProcessStartInfo(); p.FileName = "iexplore.exe"; p.Arguments = "http://www.google.com"; p.WindowStyle = ProcessWindowStyle.Minimized; Process.Start(p); This opens IE in a new, minimized window. Good, just what I want. If I try the exact same thing but instead supply Firefox in the p.FileName, it opens Firefox in a "normal" window, rather than minimized. I've tried various changes to arguments, also have tried examining my local Firefox settings (under Tools/Options) with no luck. I'm sure I'm just missing something simple, but can't figure out what it is. If anyone can help me with getting Firefox opened in a minimized state it would be greatly appreciated!

    Read the article

  • Trying to run psexec to remote to server and recycle app pool

    - by James
    If I run this from my command prompt it works fine. psexec \ServerName cscript.exe iisapp.vbs /a AppName /r I'm trying to do the same thing with C# console app. I'm using the below code but most of the time the application hangs and doesn't complete, and the few times it does it throws an error code. Am I doing this wrong? Anyone know where I can look up the error or error code? static void RecycleAppPool(string sServer) { Console.Clear(); ProcessStartInfo p = new ProcessStartInfo("psexec.exe", "\\\\" + sServer + " cscript.exe iisapp.vbs /a <AppName> /r"); p.RedirectStandardInput = true; p.UseShellExecute = false; Process.Start(p); } When it completes with error, looks like this "cscript.exe exited with error code -2147024664"

    Read the article

  • Passing Text for command line

    - by Kasun
    Hi, I need to pass some text which is in richtext box to command line. This is my Button click even which start the cmd. private void button1_Click(object sender, EventArgs e) { ProcessStartInfo psi = new ProcessStartInfo { FileName = "cmd", Arguments = @"/k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat""", }; Process.Start(psi); } In my rich text box contain following text. include iostream using namespace std; int main() { cout << "Welcome to the wonderful world of C++!!!\n"; return 0; } Can anyone provide me necessary codes.

    Read the article

  • Run a method from an exe file

    - by Lily
    Hi I need to call a method from an exe file ProcessStartInfo startInfo = new ProcessStartInfo(@"exeParser.exe"); startInfo.WindowStyle = ProcessWindowStyle.Normal; startInfo.CreateNoWindow = false; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; startInfo.Arguments = ?? I don't know how to call a method and pass parameters Any help please?? The executable is mine but I'm having trouble using the things in a web app so I thought it would be better to call it as a process Thanks

    Read the article

  • Call Babel .Net Obfuscator from C# Code

    - by aron
    Hello, I have a C# WinForms app that I use to create software patches for my app. In noticed that Babel .Net includes Babel.Build.dll and Babel.Code.dll Is there a way, in my C# code, I can call Babel .Net something like: ExecuteCommand(C:\Program Files\Babel\babel.exe "C:\Patch\v6\Demo\Bin\Lib.dll" --rules "C:\Patch\babelRules.xml", 600) Here's a common script to execute a CMD prompt in C#. However if I just include the Babel.Build.dll in my winform I may be able to do it seamlessly. public static int ExecuteCommand(string Command, int Timeout) { int ExitCode; ProcessStartInfo ProcessInfo; Process Process; ProcessInfo = new ProcessStartInfo("cmd.exe", "/C " + Command); ProcessInfo.CreateNoWindow = true; ProcessInfo.UseShellExecute = false; Process = Process.Start(ProcessInfo); Process.WaitForExit(Timeout); ExitCode = Process.ExitCode; Process.Close(); return ExitCode; }

    Read the article

  • How do I launch a subprocess in C# with an argv? (Or convert agrv to a legal arg string)

    - by lucas
    I have a C# command-line application that I need to run in windows and under mono in unix. At some point I want to launch a subprocess given a set of arbitrary paramaters passed in via the command line. For instance: Usage: mycommandline [-args] -- [arbitrary program] Unfortunately, System.Diagnostics.ProcessStartInfo only takes a string for args. This is a problem for commands such as: ./my_commandline myarg1 myarg2 -- grep "a b c" foo.txt In this case argv looks like : argv = {"my_commandline", "myarg1", "myarg2", "--", "grep", "a b c", "foo.txt"} Note that the quotes around "a b c" are stripped by the shell so if I simply concatenate the arguments in order to create the arg string for ProcessStartInfo I get: args = "my_commandline myarg1 myarg2 -- grep a b c foo.txt" Which is not what I want. Is there a simple way to either pass an argv to subprocess launch under C# OR to convert an arbitrary argv into a string which is legal for windows and linux shell? Any help would be greatly appreciated.

    Read the article

  • Can not start an desktop application in C#'s Process

    - by Don
    I try to pragrammatically run applications such as notepad.exe and Calc.exe with the following codes. I can see the application is activated in Process Exprorer but the application UI does not appear on the screen. I got this info inside the process p - "Process must exit before requested information can be determined" and the exitcode are 1200, 5084, etc. What is wrong? Thanks! Codes - ProcessStartInfo pInfo = new ProcessStartInfo(@"C:\Windows\system32\notepad.exe"); pInfo.UseShellExecute = false; pInfo.CreateNoWindow = false; pInfo.WindowStyle = ProcessWindowStyle.Normal; Process p = Process.Start(pInfo); p.EnableRaisingEvents = true; int exitCode = p.Id; p.WaitForExit(); p.Close();

    Read the article

  • How to execute commands in Command Prompt using c#

    - by karthik
    I want to execute these steps in CMD using c# 1 - CD C:\MySQL\MySQL Server 5.0\bin 2 - mysqldump -uroot -ppassword sample d:\Test\222.sql On manually doing this, i will get file named "222.sql" I am using the below code to do it, but missing something.. Nothing Happens public void CreateScript_AAR() { string commandLine = @"CD C:\MySQL\MySQL Server 5.0\bin\mysqldump -uroot -ppassword sample> d:\Test\222.sql"""; System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo("cmd.exe"); PSI.RedirectStandardInput = true; PSI.RedirectStandardOutput = true; PSI.RedirectStandardError = true; PSI.UseShellExecute = false; System.Diagnostics.Process p = System.Diagnostics.Process.Start(PSI); System.IO.StreamWriter SW = p.StandardInput; System.IO.StreamReader SR = p.StandardOutput; SW.WriteLine(commandLine); SW.Close(); }

    Read the article

  • ResGen.exe stucks when redirect output

    - by Darqer
    Hello I try to redirect standard output from ResGen.exe. I use following code ProcessStartInfo psi = new ProcessStartInfo( "resxGen.exe" ); psi.CreateNoWindow = true; psi.Arguments = sb.ToString(); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; Process p = Process.Start( psi ); p.WaitForExit(); StreamReader sr = p.StandardOutput; string message = p.StandardOutput.ReadToEnd(); It stuck on p.WaitForExit. When I turn off output stream redirection and do not read StandardOutput it works correctly. What do I do wrong ?

    Read the article

  • Process.Exited event is not be called

    - by liys
    Hi all, I have the following code snippet to call into command line: p = new Process(); ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "cmd.exe"; psi.Arguments = "/C " + "type " + “[abc].pdf”; psi.UseShellExecute = false; psi.RedirectStandardInput = false; psi.RedirectStandardOutput = true; psi.CreateNoWindow = true; p.StartInfo = psi; p.EnableRaisingEvents = true; p.Exited += new EventHandler(p_Exited); p.Start(); p.WaitForExit(); Strangely, When [abc] is a small pdf file(8kb) p_Exited is called. But when it's a large pdf file(120kb) it is never called. Any clues? Thanks,

    Read the article

  • How to add authentication property for login to directory path when running batch file in WCF?

    - by blankon91
    I have class in my WCF service to execute batch file. when I test to run the batch file in shared directory, everything is fine, the batch was executed, but when I try to run the batch file from secure diretory, I get error "ACCESS DENIED". How to add login property so I can access my secured directory to execute my batch file? here is my code: public string ExecuteBat() { string hasil = ""; ProcessStartInfo processInfo = new ProcessStartInfo(@"D:\Rpts\SSIS_WeeklyFlash_AAF_1.bat"); processInfo.CreateNoWindow = true; processInfo.UseShellExecute = false; Process process = Process.Start(processInfo); process.WaitForExit(); if (process.ExitCode == 0) { hasil = "BAT EXECUTED!"; } else { hasil = "EXECUTE BAT FAILED"; } return hasil; }

    Read the article

  • How to avoid the Windows (XP) Security Warning when launching a "DOS" command line within C#?

    - by Will Marcouiller
    This question is related to this initial question asked a little while ago. Now, that I have chosen the extracting tool, I'm iterating through a given in command line parameter directory and subdirectories to extract the compressed .zip files. private static void ExtractAll(DirectoryInfo _workingFolder) { if(_workingFolder == null) { Console.WriteLine("Répertoire inexistant."); return; } foreach (DirectoryInfo subFolder in _workingFolder.GetDirectories("*", SearchOption.AllDirectories)) foreach(FileInfo zippedFile in subFolder.GetFiles("*.zip", SearchOption.AllDirectories)) { if(zippedFile.Exists) { ProcessStartInfo task = new ProcessStartInfo(@".\Tools\7za.exe", string.Format("x {0}", zippedFile.FullName)); Process.Start(task); } } } But everytime I start a 7za process, the Windows Security Warning prompts. I would like to avoid such annoying behaviour, so here's my question: How to avoid the Windows (XP) Security Warning when launching a "DOS" command line within C#?

    Read the article

  • calling command line from .NET application

    - by Roman Dorevich
    I want to call from a c# application a command line starting from it an application and retrieve the stat from it. I did this but something is missing: ProcessStartInfo psf = new ProcessStartInfo("cmd.exe", "/C time"); psf.WindowStyle = ProcessWindowStyle.Hidden; psf.RedirectStandardOutput = true; psf.UseShellExecute = false; psf.CreateNoWindow = true; Process p = Process.Start(psf); StreamReader sr = p.StandardOutput; p.WaitForExit(); What is wrong ?

    Read the article

  • gtk-sharp-2.0 hide/show external applications(processes)

    - by ziuciek
    Hi, maybe the topic isn't quite precise.. i want to write in c# (gtk#-2.0) an app which opens another app hidden and later shows that app. For now i know only how to open hidden app... in windows...: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Diagnostics; namespace do_kasacji { class Program { static void Main(string[] args) { ProcessStartInfo info = new ProcessStartInfo(); info.WindowStyle = ProcessWindowStyle.Minimized; info.FileName = "notepad"; using (Process pr = Process.Start(info)) { pr.WaitForExit(); } } } } Anyone knows how to change it so hat it would run in linux?

    Read the article

  • C# windows service location

    - by user743246
    By using following code[C#], we can know the path where googlechrome is installed. But, this code first starts chrome.exe, then takes its path. My question is without starting chrome.exe, how can I know the path? ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "chrome.exe"; string argmnt = @"-g"; startInfo.Arguments = argmnt; String path = null; try { Process p = Process.Start(startInfo); path = p.MainModule.FileName; p.Kill(); } catch (Exception e) { return String.Empty; }

    Read the article

  • Vboxheadless without a command prompt (VirtualBox)

    - by joe
    I'm trying to run VirtualBox VM's in the background from a service. I'm having trouble starting a process the way I desire. I'd like to start the virtualbox guest in headless mode as a separate process and show nothing as far as GUI. Here's what I've tried: From command line: start vboxheadless -s "Ubuntu Server" In C#: ProcessStartInfo info = new ProcessStartInfo { UseShellExecute = false, RedirectStandardOutput = true, ErrorDialog = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, FileName = "C:/program files/sun/virtualbox/vboxheadless", Arguments = "-s \"Ubuntu Server\"" }; Process p = new Process(); p.StartInfo = info; p.Start(); String output = p.StandardOutput.ReadToEnd(); //BLOCKS! (output stream isnt closed) I want to be able to get the output to know if starting the server was a success. However, it seems as though the window that's spawned never closes its output stream. It's also worth mentioning that I've tried using vboxmanage startvm "Ubuntu Server" --type=vrdp. I can determine whether the server started properly using this. But it shows a new command prompt window for the newly started VirtualBox guest.

    Read the article

  • Why won't Google Chrome install on my Windows 7?

    - by quakkels
    I can tell something is wrong with my computer. A little history: Google Chrome was not running correctly. When i was using facebook, any link on face that ran an ajax javascript function would not work. No error was being thrown, it just wasn't working. I uninstalled Chrome and reinstalled it. On re-install, a toolbar automatically installed with Chrome. BitTorrentBar. I did not install BitTorrentBar, it installed on it's own. Bad. When BitTorrentBar was active, then ajax functions on facebook worked. When I deactivated or uninstalled BittorrentBar from Chrome extensions, then ajax stopped working. I ran scanned the computer with Avast (free version) and SpyBot Search and Destroy (also free). They found nothing wrong. I uninstalled Chrome using Control Panel and then I went through my file system deleting anything that had "google", "BitTorrent", "chrome", or "conduit". Conduit seems to distribute BitTorrentBar. After doing all that, I tried to reinstall Chrome. I got this error: System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at ClickOnceBootStrap.ClickOnceEntry.Main() This error interupts the Chrome install every time! computer scans don't show anything wrong. So then, I thought this might be a .net framework error. Perhaps I deleted something I wasn't supposed to. So I reinstalled .NET Framework 4 and checked the repair option. I also ran Windows Updates. When I tried to download Chrome, again I got the same error as listed above. What should I do?

    Read the article

  • C#/.NET: Process.HasExited returns true even though process is running??

    - by johnrl
    I have been observing that Process.HasExited sometimes returns true even though the process is still running. My code below starts a process with name "testprogram.exe" and then waits for it to exit. The problem is that sometimes I get thrown the exception; it seems that even though HasExited returns TRUE the process itself is still alive in the system - how can this be?? My program writes to a logfile just before it terminates and thus I need to be absolutely sure that this logfile exists (aka the process has terminated/finished) before reading it. Continuously checking for it's existence is not an option. // Create new process object process = new Process(); // Setup event handlers process.EnableRaisingEvents = true; process.OutputDataReceived += OutputDataReceivedEvent; process.ErrorDataReceived += ErrorDataReceivedEvent; process.Exited += ProgramExitedEvent; // Setup start info ProcessStartInfo psi = new ProcessStartInfo { FileName = ExePath, UseShellExecute = false, // Must be false to redirect IO RedirectStandardOutput = true, RedirectStandardError = true, Arguments = arguments }; process.StartInfo = psi; // Start the program process.Start(); while (!process.HasExited) Thread.Sleep( 500 ); Process[] p = Process.GetProcessesByName( "testprogram" ); if ( p.Length != 0 ) throw new Exception("Oh oh");

    Read the article

  • WCF selfhosted service, installer class and netsh

    - by jeho
    I have a selfhosted WCF service application which I want to deploy by a msi installer package. The endpoint uses http port 8888. In order to startup the project under windows 2008 after installation I have to either run the program as administrator or have to edit the http settings with netsh: "netsh http add urlacl url=http://+:8888/ user=\Everyone" I want to edit the http settings from my installer class. Therefore I call the following method from the Install() method: public void ModifyHttpSettings() { string parameter = @"http add urlacl url=http://+:8888/ user=\Everyone"; System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("netsh", parameter); psi.Verb = "runas"; psi.RedirectStandardOutput = false; psi.CreateNoWindow = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; System.Diagnostics.Process.Start(psi); } This method will work for english versions of windows, but not for localized versions (The group Everyone has different names in localized versions). I have also tried to use Environment.UserName to allow access at least for the current logged on user. But this does also not work, because the installer class is run by the msi service which runs under the user SYSTEM. Hence Enviroment.UserName returns SYSTEM and that is not what I want. Is there a way to grant access to all (or at least for the current logged on) user to my selfhosted WCF service from a msi installer class?

    Read the article

  • Invoking brill tagger through C#

    - by Toshal Mokadam
    We want to use brill tagger such that on a button click, it will tag the Input.txt into output.txt. So we have created a new visual studio project and put a button. On button click event we wrote the following code. There are no errors and we can see the command prompt getting invoked. But the output file is not getting created. The code is as follows. could you pls guide us?? private void button1_Click(object sender, EventArgs e) { ProcessStartInfo brillStartInfo = new ProcessStartInfo(@"C:\Users\toshal\Documents\Visual Studio 2008\Projects\brill tagger\bin\brill.exe"); brillStartInfo.Arguments = "/C brill.exe LEXICON.BROWN Input.txt BIGRAMS LEXICALRULEFILE.BROWN CONTEXTUALRULEFILE.BROWN > output.txt"; brillStartInfo.UseShellExecute = false; brillStartInfo.RedirectStandardOutput = true; brillStartInfo.RedirectStandardError = true; brillStartInfo.CreateNoWindow = false; Process brill = new Process(); brill.StartInfo = brillStartInfo; brill.Start(); string output = brill.StandardOutput.ReadToEnd(); brill.WaitForExit(); }

    Read the article

  • How to open a help webpage after installation is complete

    - by Kapil
    I have built an installer for my windows app using the VisualStudio 2008 IDE. I also use some custom-actions to do a few extra stuff at the time of installation/uninstallation. What I also want to do is that when the installation is completed, the installer should launch a help webpage or a getting-started page for the users to know how to go ahead with the app. I am doing the following for this: private void CustomInstaller_Committed(object sender, InstallEventArgs e) { System.Windows.Forms.LinkLabel lbl = new System.Windows.Forms.LinkLabel(); lbl.Links.Remove(lbl.Links[0]); lbl.Links.Add(0, lbl.Text.Length, "http://www.mywebsite.com/help.aspx"); ProcessStartInfo pInfo = new ProcessStartInfo(lbl.Links[0].LinkData.ToString()); Process.Start(pInfo); } Also, I set the event handler as such: this.Committed += new InstallEventHandler(CustomInstaller_Committed); This is launching the webpage, but not at the right point in the flow where I would have wanted it. It launches the IE browser even before the user dismisses the installation window (i.e clicks 'Close' in the Installation Completed dialog box). I want the webpage to open only when the user finally dismisses the installation. Any ideas how can I achieve this? Thanks, Kapil

    Read the article

  • How to print PDF on default network printer using GhostScript (gswin32c.exe) shell command

    - by Maciej
    I'd like to print PDF file(s) on windows' network printer via GhostScript. (I dont want to use Adobe Reader) I've read gswin32c.exe which can do the job. I experimented with many commands and coudn't find the way how to force gs to print PDF on my (windows default) network drive. I don't need point exact network printer- default can be used. But if there is no such option I'm happy to pass printer name as well. (I've tried with param -SDevice="\server_IP\printer_name" but this didnt work as well...) Command working under Windows cmd: gswin32c -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 -sDEVICE=ljet4 -sOutputFile="\\spool\\\Server_Name\Printer_name" "C:\test.pdf" Method created base on above - doesnt work and thorws exception. (Error code = 1) /// <summary> /// Prints the PDF. /// </summary> /// <param name="ghostScriptPath">The ghost script path. Eg "C:\Program Files\gs\gs8.71\bin\gswin32c.exe"</param> /// <param name="numberOfCopies">The number of copies.</param> /// <param name="printerName">Name of the printer. Eg \\server_name\printer_name</param> /// <param name="pdfFileName">Name of the PDF file.</param> /// <returns></returns> public bool PrintPDF (string ghostScriptPath, int numberOfCopies, string printerName, string pdfFileName) { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.Arguments = " -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=" + Convert.ToString(numberOfCopies) + " -sDEVICE=ljet4 -sOutputFile=\"\\\\spool\\" + printerName + "\" \"" + pdfFileName + "\""; startInfo.FileName = ghostScriptPath; startInfo.UseShellExecute = false; Process process = Process.Start(startInfo); return process.ExitCode == 0; } Any idea how to make it working under C#?

    Read the article

  • Alternative native api for Process.Start

    - by Akash Kava
    Ok this is not duplicate of "http://stackoverflow.com/questions/2065592/alternative-to-process-start" because my question is something different here. I need to run a process and wait till execution of process and get the output of console. There is way to set RedirectStandardOutput and RedirectStandardError to true, however this does not function well on some machines, (where .NET SDK is not installed), only .NET runtime is installed, now it works on some machines and doesnt work on some machines so we dont know where is the problem. I have following code, ProcessStartInfo info = new ProcessStartInfo("myapp.exe", cmd); info.CreateNoWindow = true; info.UseShellExecute = false; info.RedirectStandardError = true; info.RedirectStandardOutput = true; Process p = Process.Start(info); p.WaitForExit(); Trace.WriteLine(p.StandardOutput.ReadToEnd()); Trace.WriteLine(p.StandardError.ReadToEnd()); On some machines, this will hang forever on p.WaitForExit(), and one some machine it works correctly, the behaviour is so random and there is no clue. Now if I can get a real good workaround for this using pinvoke, I will be very happy.

    Read the article

< Previous Page | 1 2 3 4  | Next Page >