w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Start and manage external process from a WPF app
For your immediate question, there is nothing new in the recent versions of .NET that gives a better or more up-to-date way to start a local executable. Process.Start is (and has been) the way to go. The simplest, and most convenient, is to select one of the five static methods on Process. Passing strings or a populated StartInfo instance. You would use the latter if you needed more control over how the process got raised. Or of interest in your case, if you wanted to pipe the program's stdio as a stream into your own application. Here's a sample of populating a Start Info instance from one of my utilities... ProcessStartInfo start = new ProcessStartInfo(BaseIoConstantsProvider.CommandProcessor) { Arguments = BaseIoConstantsProvider.KeepAlive,

Categories : C#

How to get process (external program) time, cpu usage for process run from java application?
Run this program in a separate thread, then run tasklist /v process (if Windows), intercept output, split lines into columns, find my-simple-app.exe and get necessary info. If tasklist info is not enough, then read process ID column form tasklist output and run some other util to get more info.

Categories : Java

Using Start-Process for starting a process having its full command line
Do you need start-process? Can you invoke the executable directly? & "C:Dir 1Dir 2executable.exe" -arg1 "value 1" -arg2 "value 2" See help about_Operators and for info on & (call) operator. Bill

Categories : Powershell

Check if a process started with Process.Start is still running?
I found a way to check if one process has the file in his "CommandLine", meaning that it is currently editing the application: private static void OpenProcessIfNeeded(String file) { using (ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process")) { foreach (ManagementObject mo in mos.Get()) { if (mo["CommandLine"] != null && mo["CommandLine"].ToString().IndexOf(file, StringComparison.InvariantCultureIgnoreCase) > -1) { Console.WriteLine("Found!: " + mo["CommandLine"]); return; } } } Process.Start(file); }

Categories : C#

Does a process started by C# Process.Start() inherit ErrorMode?
If you watch with resharper/ilspy and/or you watch the sources of .NET you'll see that in Process.StartWithCreateProcess(ProcessStartInfo startInfo) all the magic happens. num2 is the variable that contains the dwCreationFlags. Your flag isn't visible anywhere. Sometimes StartWithCreateProcess sets the 0x8000000 (CREATE_NO_WINDOW) (if the CreateNoWindow parameter is set) and the 0x400 (CREATE_UNICODE_ENVIRONMENT) (if the system is NT based) flags, but that's all.

Categories : C#

Process.Start() with arguments to start Google Chrome
You can use shortcut when call the chrome.exe instead using full path location. Module Module1 Sub Main() System.Diagnostics.Process.Start("chrome.exe", "--incognito") End Sub End Module More: start-google-chrome-from-run-windows-key-r UPDATE I found what is your problem in your code. Your code using –-incognito in the parameter, but it should be --incognito. See the first character in that parameter. Should be - instead –. Module Module1 Sub Main() System.Diagnostics.Process.Start("C:Program Files (x86)GoogleChromeApplicationchrome.exe", "--incognito") End Sub End Module

Categories : Dotnet

process writes to its own log, but not with Process.start
You have to read the result after the process has finished: exeProcess.Start(); exeProcess.WaitForExit(); string result = reader.ReadToEnd(); Console.WriteLine(result);

Categories : C#

Powershell Start-Process to start Powershell session and pass local variables
I'm pretty sure there's no direct way to pass variables from one PowerShell session to another. The best you can do is some workaround, like declaring the variables in the code you pass in -ArgumentList, interpolating the values in the calling session. How you interpolate the variables into the declarations in -ArgumentList depends on what types of variables. For an array and a string you could do something like this: $command = '<contents of your scriptblock without the curly braces>' Start-Process powershell -ArgumentList ("`$Array = echo $Array; `$String = '$String';" + $command)

Categories : Powershell

Get object in external process. Is it possible? (c#)
Apart from the obvious (WCF), there is a ZeroMQ binding for C#/CLR which is pretty good: http://www.zeromq.org/bindings:clr Does message-oriented IPC, pub/sub and various other strategies with much less code and config than WCF. It's also at least an order of magnitude faster than anything else and has less latency if you require low latency comms. With respects to semaphores, locks, mutexes etc. If you share by communicating rather than communicate by sharing, you'll have a whole load less hassle than the traditional paradigm.

Categories : C#

How can I wait until an external process has completed?
You need to wait until the process handle is signaled. For example by a call to WaitForSingleObject. Obviously CreateProcess returns you a process handle on which you can wait. You cannot persuade ShellExecute to return a process handle, but its more capable brother ShellExecuteEx will do so. However, I personally would choose CreateProcess here. You will get more flexibility and control, and it's not that complex. For example, you can suppress display of the console window if you wish.

Categories : Delphi

Sending output to external process
Your code has a few problems. First, you generally should not use exceptions for your regular control flow: it's expensive, it's difficult to read, and it makes handling actual errors more difficult. It's generally better to spawn another Thread that calls p.waitFor() and signals your main thread to complete, such as with wait/notify. Also, your construction with the infinite loop and using break instead of return will make your code more difficult to debug; instead, use a Timer. It looks like the output to your external program probably is working correctly but that the problem is just with reading its output. The program may be buffering its own output or may be detecting that it's not being run interactively and behaving differently.

Categories : Java

Seeding Carrierwave from external process
Carrierwave downloads the remote file as soon as you assign it via model.remote_image_url=, and it moves the file to its final location (local storage, S3, etc) as soon as you call model.save. This happens synchronously, so if model.save has completed, and there hasn't been an error, your file has been stored. To put it another way: If you just loaded a model from the database, and model.image? is true, then model.image.url should be a working URL.

Categories : Ruby On Rails

How to monitor an external process for events by its PID in C?
If you can run as root, then you can use the netlink interface proc events: http://bewareofgeek.livejournal.com/2945.html I just compiled it cleanly on fedora 17 x86_64 and it gives me this: [root@hip1 yotest]# ./proc set mcast listen ok fork: parent tid=2358 pid=2358 -> child tid=21007 pid=21007 exec: tid=21007 pid=21007 fork: parent tid=21007 pid=21007 -> child tid=21008 pid=21008 fork: parent tid=21007 pid=21007 -> child tid=21009 pid=21009 fork: parent tid=21007 pid=21007 -> child tid=21010 pid=21010 fork: parent tid=21007 pid=21007 -> child tid=21011 pid=21011 exec: tid=21010 pid=21010 exec: tid=21008 pid=21008 exec: tid=21011 pid=21011 exec: tid=21009 pid=21009 exit: tid=21008 pid=21008 exit_code=0 fork: parent tid=21010 pid=21010 -> child tid=21012 pid=21012 exi

Categories : C

Process.Start in ASP.NET?
You can try http://support.microsoft.com/default.aspx?scid=kb;en-us;317012 or else, it might be a folder security issue. The folder in which the files are kept, must have Modify access to Users. IIS_WPG under which IIS Process run, that user belongs to Users group, this user must have Modify access on the folder.

Categories : Asp Net

How to communicate with an external Python process? (not a subprocess)
If you can accept communicating between the processes using a tcp connection, you could use zeromq. http://zeromq.org/ See these threads for examples: interprocess communication in python how to communicate two separate python processes?

Categories : Python

How to change active file in external process?
If I understood your question properly and you try to let other processes to access your main application process you might want to read about Interop Marshaling: http://msdn.microsoft.com/en-us/library/eaw10et3.aspx

Categories : C#

Is there a way to process a DBF file in Java without external libraries?
The original DBF format is pretty simple. So if you only have to read .dbf files, it's not that hard, see Wikipedia. If you have read the header, you should be able to "jump" directly to the records. There are plenty of resources on the web; for example on SO: As for the header, have a look at this As for reading the records, look here So I would just give it a try to read it using java.io.RandomAccessFile

Categories : Java

Capture the result from the terminal (external process)
Use the subprocess module import subprocess p = subprocess.Popen("ls -l | grep %s | awk '{ print $9 }'" % mask, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() The shell=True is required as the pipeline is run by the shell, otherwise you get a No such file or directory. In Python 2.7 you can also use output = subprocess.check_output( "ls -l | grep %s | awk '{ print $9 }'" % mask stderr=subprocess.STDOUT, shell=True) But I find it cumbersome to use as it throws a subprocess.CalledProcessError if the pipeline returns exit code other than 0, and to capture both stdout and stderr you need to interleave them both, which makes it unusable for many cases.

Categories : Python

Running external process as non blocking Java
You need to empty the inputstream from the process or it will act "weird" when it fills the buffer size. Assuming p is the process returned by .exec(): BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); String in; while ((in = br.readLine()) != null); You can change the while loop to add { } and actually print the tomcat output if you'd like, but really all you need is to empty the buffer.

Categories : Java

Detect when memory moves in an external .NET process?
An attacker can use the CLR Profiling API to receive callbacks when the GC moves objects around, which can be used to reliably track moving references. http://msdn.microsoft.com/en-us/library/hh361123.aspx

Categories : C#

External command-line process never returns
I think you probably just need to call Dim ret = myOutput.ReadToEnd before proc.WaitForExit(). MSDN warns about a deadlock from calling WaitForExit() first: "A deadlock condition can result if the parent process calls p.WaitForExit before p.StandardOutput.ReadToEnd and the child process writes enough text to fill the redirected stream. The parent process would wait indefinitely for the child process to exit. The child process would wait indefinitely for the parent to read from the full StandardOutput stream." So I'm guessing those 3/81 files just have more output than the others.

Categories : Dotnet

How to Start a Process Unelevated
The Win32 Security Management functions provide the capability to create a restricted token with normal user rights; with the token, you can call CreateProcessAsUser to run the process with that token. Below is a proof of concept that runs cmd.exe as a normal user, regardless of whether the process is run in an elevated context. // Initialize variables. IntPtr hSaferLevel, hToken; STARTUPINFO si = default(STARTUPINFO); SECURITY_ATTRIBUTES processAttributes = default(SECURITY_ATTRIBUTES); SECURITY_ATTRIBUTES threadAttributes = default(SECURITY_ATTRIBUTES); PROCESS_INFORMATION pi; si.cb = Marshal.SizeOf(si); // The process to start (for demonstration, cmd.exe) string ProcessName = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.System), "cmd.exe"); // Create t

Categories : C#

Start Process with Parameters
Try this instead: ProcessStartInfo startInfo = new ProcessStartInfo(yol + "\" + "samp.exe"); startInfo.Arguments = "-c -h192.168.1.2 -n" + textBox1.Text; Process.Start(startInfo);

Categories : C#

Wait for process start
The Ugly Way Generally, when waiting for a process to finish loading, you would call Process.WaitForInputIdle() From MSDN : Causes the Process component to wait indefinitely for the associated process to enter an idle state. This overload applies only to processes with a user interface and, therefore, a message loop. With explorer.exe this will most likely not work, as this process often spawns a child process and instantly dies. The workaround would be to launch the process, Sleep for say, 250-500ms, then find the new Process using some godawful hack, and then call WaitForInputIdle on that Process. An Alternative If you are willing to start explorer.exe minimized, you could do it like this: ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "explorer.exe"; psi.Arg

Categories : C#

Run R script with start.process in .net
this is how it works for me: Dim myprocess As New Process myprocess.StartInfo = New ProcessStartInfo("C:Program Files (x86)RR-2.6.2inR.exe", "CMD BATCH C:/Users/test/test3.R C:/Users/test/testout.csv") myprocess.Start() second approach (first app. doesnt give me a good csv output so here this is a workaround): Dim proc = New Process proc.StartInfo.FileName = "C:Program Files (x86)RR-2.6.2inRscript.exe" proc.StartInfo.WorkingDirectory = "C:Program Files (x86)RR-2.6.2in" proc.StartInfo.Arguments = "C:/Users/Desktop/RtoVB/test4.r" proc.StartInfo.UseShellExecute = True proc.StartInfo.RedirectStandardOutput = False proc.Start()

Categories : Dotnet

Cannot run an .exe program by using Process.Start() in c#
Try This var processStartInfo = new ProcessStartInfo(Directory.GetCurrentDirectory() + "\ThaoLapT64S\module1.exe"); processStartInfo.WorkingDirectory = Path.GetDirectoryName(Directory.GetCurrentDirectory() + "\ThaoLapT64S\module1.exe"); Process.Start(processStartInfo);

Categories : C#

VS C++ Form Process::Start
How about: Process::Start( "C:\Program Files<path> esseract.exe" "in_image out_text" ); msdn documentation

Categories : C++

How to start an external jar in the same JVM and still be able to terminate current main()
I think that it would be far simpler to do this with a separate virtual machine and a wrapper script. Your problem at step 5 is that it requires the application to "shut down" without calling System.exit and without running the shutdown hooks: This could require major re-engineering of your application code-base. Even after you've done that, you still have the problem that old application state is likely to "linger" via objects loaded using the old classloader. Getting rid of that could be really difficult. And if you don't then: you've got a permgen leakage, you may have a non-permgen memory leaks (e.g. via statics in classes that have been replaced), and you may have leakage of application state that could cause problems for the "relaunched" application.

Categories : Java

send SIGINT signal from Java to an external process
If you tried to signal SIGINT to your process from the console, and it did not react, then this has nothing to do with Java, but your process just does not handle this signal. Try sending the more radical (non ignorable) SIGKILL signal.

Categories : Java

Time out for external process completion in perl (windows)
Signals are a unix concept. Instead, you should use IPC::Run. use IPC::Run qw( run timeout ); run [ 'bla', 'arg' ], '>&', my $results, timeout( 10 ) or die "bla: $?"

Categories : Perl

Android exception - External allocation too large for this process
try the following code :- public static Bitmap createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) { Matrix m; synchronized (Bitmap.class) { // small pool of just 1 matrix m = sScaleMatrix; sScaleMatrix = null; } if (m == null) { m = new Matrix(); } final int width = src.getWidth(); final int height = src.getHeight(); final float sx = dstWidth / (float)width; final float sy = dstHeight / (float)height; m.setScale(sx, sy); Bitmap b = Bitmap.createBitmap(src, 0, 0, width, height, m, filter); synchronized (Bitmap.class) { // do we need to check for null? why not just assign everytime? if (sScaleMatrix == null) { sScaleMatrix = m; } }

Categories : Android

Some Process.Start commands not working
Summarizing what I put in the comments - you're seeing the issue because you're running in a 32-bit process that is then subject to File System Redirection - your attempts to access the System directory get redirected to (by default) C:WindowsSysWOW64. This directory doesn't contain an msconfig.exe. Visual Studio 2012, introduced a AnyCPU Prefer 32-bit option, and that is selected by default. Best advice would be to switch your build platform to 64-bit, or uncheck Prefer 32-bit.

Categories : C#

Start a background process with javascript
You can do this by writing a plugin. It's possible to write plugins that work on most popular browsers, using the same C++ code, using a library called Firebreath Naturally there is no pre-existing standard plugin that allows the page to start any external application, because that would be a massive security hole and no (sane) user would agree to install such a plugin. You have to write a specific plugin with capabilities carefully limited to what you need, so the user can agree to let you use just those capabilities. Again, think about how another page might exploit those capabilities before going down this route.

Categories : Javascript

C# Wait for a Progam/Process to start
You could use the Thread.Sleep method in your while loop to prevent excessive CPU consumption. It's not optimal, but it's simple. If you need something better, try using events. This page describes how to use the ManagementEventWatcher to do so.

Categories : C#

Process.Start () with passed through Stdout
var pi = new ProcessStartInfo { FileName = prog, Arguments = args, UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = false }; var proc = new Process { StartInfo = pi }; try { if (!proc.Start()) { throw new ApplicationException("Starting proc failed!"); } Console.WriteLine(proc.StandardOutput.ReadToEnd()); proc.WaitForExit(); if (proc.ExitCode != 0) { //throw new ApplicationException(String.Format("proc returned exit code {0}", proc.ExitCode)); } } catch (Exception ex)

Categories : C#

Start process as other user as administrator c#
Set : info.UseShellExecute = true; An example : ProcessStartInfo proc = new ProcessStartInfo(); proc.UserName = "usernamer"; proc.Domain = "dm"; proc.Password = securePasswordString; proc.LoadUserProfile = false; proc.UseShellExecute = false; proc.WorkingDirectory = Environment.CurrentDirectory; proc.FileName = Application.ExecutablePath; proc.Verb = "runas"; try { Process.Start(proc); } catch { // The user refused the elevation. // Do nothing and return directly ... return; } Application.Exit(); // Quit itself

Categories : C#

Why does Process.Start(ProcessStartInfo) fail?
When you do not specify the working directory, the new process will inherit the working directory of your process. That is, the new process will inherit the working directory of the process that called Process.Start(). That's the only difference between the two attempts to start MyApp. One of them inherits the working directory, and one of them specifies it. Clearly MyApp does not like to run with the initial working directory being the directory of your parent process. Why that is so, I cannot say for sure. It would seem that MyApp is attempting some XML parsing at startup. So perhaps that XML parsing reads a file that is presumed to be in the working directory. But in fact the file is located in the same directory as the executable. If that is the case then you need to modify MyApp t

Categories : C#

Error from powershell start-process
try this one... Set-Variable -Name myExe c:windowssystem32cmd.exe $proc = (start-process -FilePath $myExe -argumentList '/k' -windowStyle Minimized -passthru ) replace the cmd.exe with your exe

Categories : Powershell

Let MVC Website start Process as Administrator
As noone commented here I post how I solved the problem. As we host the server I just said via Registry that the console "Administrator" account should log on automatically. In the autostart folder of that User I've put my tool and changed it a bit. The tool now checks every view seconds if a "startCall.txt" file exists and if yes it starts the call. The website just deletes or creates that file. In that way I can control the tool even if it is in a totally different user context (which seemed to be the problem). I know it's a more or less cheap workaround but time wasn't my friend ;-)

Categories : C#

Android: how to debug app's start-up process
You should implement your own Application class which extends Application and override the methods onCreate and so.. . This class will be your starting point of your app. also set it as your application in the manifest.

Categories : Android



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.