Questions tagged [processstartinfo]

269 questions
4
votes
2 answers

Executing Batch File At This Directory

I have this code piece that used in my c# form project. I also have exp.bat file contains shell commands as below. But whatever I do, it does not create .txt file at working directory. @echo off echo "hello" > test.txt path =…
user9112647
4
votes
0 answers

How can I execute a process with run as admin rights and run as another user and capture output?

I have seen a few similar questions but not one that requires all 3 so run as privileges, run as different user and capture the STDOUT: Here is a snippet of my code it is to run the ADMT tool it needs local admin rights and domain admin rights: Dim…
Stevie187
  • 63
  • 3
4
votes
3 answers

Process WaitForExit not waiting

I have created Print spooler application to print pdf asynchronously. (Application uses veryPDF command to print from network printer) Here is Code var procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", " /c" +…
Munavvar
  • 802
  • 1
  • 11
  • 33
4
votes
2 answers

How to read from Process.StandardOutput without redirecting it? (F#)

I've got this little function that saves me some headaches from dealing with the horrible System.Diagnostics.Process API: let HiddenExec (command: string, arguments: string) = let startInfo = new System.Diagnostics.ProcessStartInfo(command) …
knocte
  • 16,941
  • 11
  • 79
  • 125
4
votes
9 answers

Can I get the arguments to my application in the original form (e.g including quotes)?

I have a .Net application that take a bunch of command line arguments, process some of it, and use the rest as arguments for another application E.g. MyApp.exe foo1 App2.exe arg1 arg2 ... MyApp.exe is my application, foo1 is a parameter that my…
Louis Rhys
  • 34,517
  • 56
  • 153
  • 221
4
votes
2 answers

perl.exe cannot be called by ProcessStartInfo

I am trying to get the following code to work so I can call a perl script from my c# program. I am developing using visual stdio 2008 on xp service pack3. myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new…
alex
  • 95
  • 3
  • 7
4
votes
1 answer

LPR command to print pcl-file from windows service not working(Now a tray application)

I've been looking around for a while for a possible solution and explanation, but I can't find anything really. The following command is being run from a windows service. The same command does function if used directly in cmd. It does not return any…
GoD1x
  • 77
  • 2
  • 10
4
votes
2 answers

Set ProcessStartInfo.EnvironmentVariables when Verb="runas"

I am developing a C# application. I need to create and pass variables to a new process and I am doing it using ProcessStartInfo.EnvironmentVariables. The new process must run elevated so I am using Verb = "runas" var startInfo = new…
user844541
  • 2,868
  • 5
  • 32
  • 60
3
votes
4 answers

How to use "<" (input redirection) with ProcessStartInfo in C#?

I have the following: C:\temp\dowork.exe < input.txt processing....... complete C:\ I try this: processArguments = " < input.txt"; pathToExe = "C:\\temp\dowork.exe"; startInfo = new ProcessStartInfo { FileName =…
sapbucket
  • 6,795
  • 15
  • 57
  • 94
3
votes
2 answers

ProcessStartInfo run exe in PATH envirionment variable

I'm trying to run an exe using ProcessStartInfo. The problem is I only want to specify the exe name, and add the executable path to the PATH environment variable in Windows. When I try to run my application I got a FileNotFoundException. Everything…
Marthijn
  • 3,292
  • 2
  • 31
  • 48
3
votes
1 answer

How to return the "return value" of a python script in C#?

I want to run a python script in C# and then want to return the "return value" of the python script into C#. My python script: def myfunc(): print("aaa") return "abc" if __name__ == "__main__": myfunc() My C# file: void Main() { …
kame
  • 20,848
  • 33
  • 104
  • 159
3
votes
3 answers

Process.Start cannot run batch file properly

I am trying to run a batch file using C# The batch file for the test purposes contains msg * Test It works if I run it manually. Then I use the following code to run this .bat file filePath = full path to batch file var startInfo = new…
3
votes
1 answer

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

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…
mrtaikandi
  • 6,753
  • 16
  • 62
  • 93
3
votes
2 answers

C#: How to get the executable path that Process.Start will use when given a file with no path?

The System.Diagnostics.Process.Start() method accepts a ProcessStartInfo class instance initialized with an executable with no path, such as Notepad.exe. After the process starts one can find the full path it used, such as …
rlarkin
  • 45
  • 6
3
votes
2 answers

Trying to run same command in command prompt not working

I am making a program that seeks out secured PDFs in a folder and converting them to PNG files using ImageMagick. Below is my code. string WorkDir = @"C:\Users\rwong\Desktop\TestFiles"; Directory.SetCurrentDirectory(WorkDir); String[] SubWorkDir =…
1 2
3
17 18