Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a bat file contains multiple dsget group commands to extract members to txt files. And I would like to execute the bat file from C# windows form. But results I got:
'dsget' is not recognized as an internal or external command,
operable program or batch file.

Below is the code:

var procinfo = new ProcessStartInfo()
{
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
FileName= "batFile",
WorkingDirectory = @"C:\\batDir",
};

proc = Process.Start(procinfo);
proc.WaitForExit();
string output = proc.StandardOutput.ReadToEnd();
string error = proc.StandardError.ReadToEnd();
proc.Close();


What I have tried:

Tried to change
UseShellExecute = true
but got the same results.
Posted
Updated 22-Aug-19 4:13am
Comments
Richard Deeming 22-Aug-19 7:01am    
Is dsget installed?

Is dsget in a directory that's part of the PATH environment variable?

Is your program running elevated / as an administrator?

The message means that the system cannot find dsget.exe in the current directory, or in a folder that is on the default PATH environment variable. Start by running a command prompt (WIN+R, "cmd", ENTER) and change directory to the batch file folder:
C:[ENTER]
CD \batdir[ENTER]
dir dsget.*[ENTER]
And see what it finds. At a guess, nothing.
They try
PATH[ENTER]
And see what folders Windows is looking at.
The easiest way around this is problem to take the full path to your exe and use that in your batch file instead of just "dsget": "C:\MyApps\TheyLiveInHere\dsget.exe"
 
Share this answer
 
Have you checked this: Dsget | Microsoft Docs[^] ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900