Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8127021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:22:17+00:00 2026-06-06T07:22:17+00:00

I have a .bat file to be executed. Inside that .bat file, at its

  • 0

I have a .bat file to be executed.

Inside that .bat file, at its end is that code

START _file_creator.bat %some_arg_name%
ENDLOCAL
EXIT

I don’t want to show the window during the execution and also I must wait until the operation doing by this .bat file is completed and then terminate the execution (at the end of the operation I see the standard text “Press any key to continue”). I need also to check the output and errors by that file, so I’m trying to use that code:

        System.Diagnostics.Process proc = new System.Diagnostics.Process();
        proc.StartInfo.FileName = @"C:\m_f\_config.bat";
        proc.StartInfo.RedirectStandardError = true;
        proc.StartInfo.RedirectStandardOutput = true;
        proc.StartInfo.UseShellExecute = false;
        proc.StartInfo.CreateNoWindow = true;

        proc.Start();
        proc.WaitForExit();
        output1 = proc.StandardError.ReadToEnd();
        proc.WaitForExit();
        output2 = proc.StandardOutput.ReadToEnd();
        proc.WaitForExit();

But all I get is the error

Windows can not find file "_file_creator.bat".
Make sure you typed the name correctly and try again.

of course if I run that .bat file with the proc.StartInfo.UseShellExecute = true it works fine, but in that case I can’t set RedirectStandardError = true and RedirectStandardOutput = true

How to fix it ?

Edit

using that code it works now

 proc.StartInfo.FileName = @"C:\m_f\_config.bat";
 proc.StartInfo.WorkingDirectory = @"C:\m_f\";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T07:22:19+00:00Added an answer on June 6, 2026 at 7:22 am

    Try setting the working directory correctly or make sure that _file_creator.bat is somewhere in the PATH. See the documentation about the working directory in conjunction with UseShellExecute:

    The WorkingDirectory property behaves differently depending on the value of the UseShellExecute property. When UseShellExecute is true, the WorkingDirectory property specifies the location of the executable. If WorkingDirectory is an empty string, it is assumed that the current directory contains the executable.

    When UseShellExecute is false, the WorkingDirectory property is not used to find the executable. Instead, it is used only by the process that is started and has meaning only within the context of the new process. When UseShellExecute is false, the FileName property must be a fully qualified path to the executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple bat file that runs an access macro when executed, i
I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I have bat-file, that make some operations. How to run this file from Delphi
I have created a .bat file that displays all the users logged in Windows
i have a batch(backup.bat)file.in that i have written a command to create a backup
I have a folder with an exe inside. I am creating a BAT file
I have a java program that is supposed to run a bat file, and
I have this line inside my BAT file: Example1Server.exe I would like to execute
I have the following problem. I got a bat file that runs testcomplete test.
I have a powershell command running when I execute a bat file, The command

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.