0

I have gCloud configured on my laptop. With Powershell gsutil ls is listing the name of bucket.

But with the following C# code I am not getting any output!

Process process = new Process();
// Configure the process using the StartInfo properties.
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = @"/k gsutil ls > C:\Users\gaurav.sharma\Desktop\Output.txt";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();

I should ideally get same response in Output.txt. But my execution is stuck and there is no output at all. What am I missing? What am I doing wrong?

James Z
  • 12,209
  • 10
  • 24
  • 44
goodmayhem
  • 3,364
  • 4
  • 16
  • 17
  • Have you checked [this thread](https://stackoverflow.com/a/71442562/18265570)? – Roopa M Jun 15 '23 at 08:00
  • Your code does not check for errors. On Windows, `gsutil` is a batch file. That means you must start an interpreter to run the batch file. Use `cmd.exe /c gsutil.cmd`. Review this [answer](https://stackoverflow.com/a/5519517/8016720) for better ways to run programs from c#. – John Hanley Jun 15 '23 at 11:44
  • Also the option `/k` is for running built-in commands. `gsutil` is definitely not a built-in command. – John Hanley Jun 15 '23 at 11:46

0 Answers0