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 737007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:40:16+00:00 2026-05-14T07:40:16+00:00

I have a c# program through which i am opening cmd window as a

  • 0

I have a c# program through which i am opening cmd window as a a process. in this command window i am running a batch file. i am redirecting the output of that batch file commands to a Text File. When i run my application everything seems to be ok.

But few times, Application is giving some error like “Can’t access the file. it’s being used by another application” at the same time cmd window is not getting closed. If we close the cmd process through the Task Manager, then it’s writing the content to the file and getting closed. Even though i closed the cmd process, still file handle is not getting released. so that i am not able to run the application next time onwards.Always it’s saying Can’t access the file. Only after restarting the system, it’s working.

Here is my code:

Process objProcess = new Process();
ProcessStartInfo objProInfo = new ProcessStartInfo();
objProInfo.WindowStyle = ProcessWindowStyle.Maximized;
objProInfo.UseShellExecute = true;
objProInfo.FileName = "Batch file path"                
objProInfo.Arguments = "Some Arguments";
if (Directory.Exists(strOutputPath) == false)
{
  Directory.CreateDirectory(strOutputPath);
}               
objProInfo.CreateNoWindow = false;
objProcess.StartInfo = objProInfo;                
objProcess.Start();                
objProcess.WaitForExit();

test.bat:

 java classname argument > output.txt

Here is my question:

  1. I am not able to trace where the problem is..

  2. How we can see the process which holding handle on ant file.

  3. Is there any suggestions for Java and .net interoperability

  • 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-05-14T07:40:16+00:00Added an answer on May 14, 2026 at 7:40 am

    In situations like this I start up the Process Explorer ( by Sysinternals, awesome tool btw ) click Ctrl+F, and enter the name of the file. It will search across all running processes and will list the file handles to this file by the applications that have it open.

    You can then either drop the handle, or kill the app – whatever you think is better )

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

Sidebar

Related Questions

I have a Java program in which an action is initiated which loops through
Lets give an over-basic example, I have a program which goes through a directory
I have written a program in C which communicates through udp with an Arduino.
I am working through problems in Accelerated C++ We have a program which stores
hello friends i have created a UDP chatting program through which the clients can
I have a simple program which loops through a resultset when a button is
I happen to have several functions which access different arguments of the program through
I have seven strings in a program named string1 through string7. The size of
I have a Windows Mobile program that accesses an attached device through a third-party
I have an iPhone app running properly in the simulator. Opening screen is a

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.