processstartinfo

ProcessStartInfo and Process in PowerShell - Authentication Error

依然范特西╮ 提交于 2019-12-04 13:31:23
问题 I have code that uses ProcessStartInfo and Process to invoke another script, and to return the output of that script. Unfortunately, I am getting errors, and I am unsure how to troubleshoot them. #script1.ps1 $abc = $args $startInfo = $NULL $process = $NULL $standardOut = $NULL <#Previously created password file in C:\Script\cred.txt, read-host -assecurestring | convertfrom-securestring | out-file C:\Script\cred.txt#> $password = get-content C:\Script\cred.txt | convertto-securestring

Get List of available Verbs (file association) to use with ProcessStartInfo in c#

99封情书 提交于 2019-12-04 05:47:05
I am trying to open and print files with the ProcessStartInfo class. (File can be anything but let`s assume it is a PDF File) ProcessStartInfo pi = new ProcessStartInfo(file); pi.Arguments = Path.GetFileName(file); pi.WorkingDirectory = Path.GetDirectoryName(file); pi.Verb = "OPEN"; Process.Start(pi); this works well for the pi.Verb = "OPEN"; . Some applications register themselves also with the verb "PRINT" but only some do. In my case (Windows PDF Viewer) I get an exception when trying to execute with the pi.Verb = "PRINT"; Is there a way to see all the verbs available for a specific type in

Process.Start filename using %temp%

百般思念 提交于 2019-12-04 04:11:26
问题 For some odd reaseon this code fails: p.StartInfo.FileName = @"%temp%\SSCERuntime_x86-ENU.msi"; and this code succes: p.StartInfo.FileName = @"C:\Users\USERNAME\AppData\Local\Temp\SSCERuntime_x86-ENU.msi"; Is there any reason I am missing? Note I just copied the path, I don't think the rest of the code is needed but I'll put it anyway: Process p = new Process(); p.StartInfo.FileName = @"%temp%\SSCERuntime_x86-ENU.msi"; p.StartInfo.Arguments = "/passive"; p.Start(); 回答1: The Process class does

Starting a process synchronously, and “streaming” the output

荒凉一梦 提交于 2019-12-03 19:52:24
问题 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

C# Open File With Associated Application passing arguments

狂风中的少年 提交于 2019-12-02 08:14:59
问题 I am trying to launch the default application registered for an extension specifying an additional argument: ProcessStartInfo p = new ProcessStartInfo(); p.Arguments = "myargument"; p.FileName = "file.ext"; Process.Start(p); The application starts correctly opening the specified file. The problem is that it is getting just one parameter (the name of the file), totally ignoring the additional "Arguments". Is it possible to do what I want? Am I doing something wrong? Thanks in advance for any

C# Open File With Associated Application passing arguments

六月ゝ 毕业季﹏ 提交于 2019-12-02 04:56:05
I am trying to launch the default application registered for an extension specifying an additional argument: ProcessStartInfo p = new ProcessStartInfo(); p.Arguments = "myargument"; p.FileName = "file.ext"; Process.Start(p); The application starts correctly opening the specified file. The problem is that it is getting just one parameter (the name of the file), totally ignoring the additional "Arguments". Is it possible to do what I want? Am I doing something wrong? Thanks in advance for any help, Paolo irritate I believe this is expected. Behind the scenes, Windows is finding the default

Process.Start filename using %temp%

为君一笑 提交于 2019-12-01 23:28:36
For some odd reaseon this code fails: p.StartInfo.FileName = @"%temp%\SSCERuntime_x86-ENU.msi"; and this code succes: p.StartInfo.FileName = @"C:\Users\USERNAME\AppData\Local\Temp\SSCERuntime_x86-ENU.msi"; Is there any reason I am missing? Note I just copied the path, I don't think the rest of the code is needed but I'll put it anyway: Process p = new Process(); p.StartInfo.FileName = @"%temp%\SSCERuntime_x86-ENU.msi"; p.StartInfo.Arguments = "/passive"; p.Start(); The Process class does not expand strings with environment variables (i.e. %temp% ). If you want to use environment variables to

Executing a process from .NET application without UAC prompt

雨燕双飞 提交于 2019-11-30 19:32:32
I have a scenario where I need to launch an EXE from my .NET application, but I can't get around the UAC prompt that pops up. The prompt is triggered even before the other EXE is launched - probably on the very call to Process.Start . I use this code for launching the app: var info = new ProcessStartInfo(path, "params"); info.Verb = "runas"; try { Process.Start(info); } catch (System.ComponentModel.Win32Exception) { // Person denied UAC escallation return false; } Both EXEs (my app and the other EXE) have this defined in their manifest: <requestedExecutionLevel level="asInvoker" uiAccess=

Starting a process synchronously, and “streaming” the output

瘦欲@ 提交于 2019-11-30 12:17:45
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

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

三世轮回 提交于 2019-11-30 06:49:54
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