1

I have some batch commands to run in the Perforce. Generally, I open the command prompt from "Perforce->Right click a file->Open Command Window Here".

I am trying to automate some task that involves running a command from Command Window that is opened from Perforce.

Using p4.Net API, How can I run the dos command from current perforce Client?

Ryota Kaneko
  • 67
  • 1
  • 7

1 Answers1

0

I believe the only thing special about "Open Command Window Here" is that:

  1. The command window current directory is set to that directory in your source tree.
  2. The P4USER, P4PORT, and P4CLIENT environment variables are configured to match the settings of the Perforce client workspace that you are using.

So you can use ordinary C#.Net techniques to run a child process. Here's a somewhat similar question that should give you some ideas (it uses Source Depot as its example, which is like Perforce but it's a different SCM; still, the overall concept should be similar): How to run cmd.exe using c# with multiple arguments?

Community
  • 1
  • 1
Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56