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

  • Home
  • SEARCH
  • 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 6352239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:09:56+00:00 2026-05-24T22:09:56+00:00

I am facing an issue to run the command batch file through C#. Actually

  • 0

I am facing an issue to run the command batch file through C#. Actually I have created a batch File named Log.bat which is used to get file size of all directory files. I put this batch file in my desktop. when I run this it successfully retrieve the directories and their files size.

My script of batch file is:

dir /s > "C:\Documents and Settings\dinesh.kumar\Desktop\LogFile.txt"

This given path is my file saved location.
Output:

Directory of C:\Documents and Settings\dinesh.kumar\Desktop\Color Cop

10/24/2007  12:08 AM            97,792 ColorCop.exe
08/10/2006  03:12 PM            26,235 ColorCop.HLP
08/10/2006  03:12 PM               372 file_id.diz
10/23/2007  11:50 PM             1,332 license.txt
10/24/2007  12:06 AM            10,877 readme.txt
           5 File(s)        136,608 bytes

Now I have developed an windows application to run that batch file in c#.
my code for run the batch file is:

protected void btnRun_Click(object sender, EventArgs e)
{
    System.Diagnostics.Process.Start("C:\\Documents and Settings\\dinesh.kumar\\Desktop\\Log.bat");
}

But when I run this application, it creates the LogFile.txt on desktop but it give the files of microsoftvisualstudio directory like this.
Output

Directory of C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

08/11/2011  12:53 PM    <DIR>          .
08/11/2011  12:53 PM    <DIR>          ..
06/29/2011  04:14 PM    <DIR>          1033
09/23/2005  02:53 AM            27,648 cmddef.dll
09/23/2005  04:24 AM           257,024 compluslm.dll
09/23/2005  03:37 AM           139,264 csformatui.dll
09/23/2005  07:15 AM            33,792 custsat.dll
09/23/2005  07:15 AM         1,038,848 dbghelp.dll
09/22/2005  11:16 PM            27,112 dteproperties.tlb
06/29/2011  04:14 PM    <DIR>          ExceptionAssistantContent
06/29/2011  04:14 PM    <DIR>          HTML
08/11/2011  12:53 PM            96,032 LogFile.txt
09/23/2005  06:56 AM            19,456 MakeZipExe.exe
09/23/2005  06:56 AM           393,216 Microsoft.Data.ConnectionUI.Dialog.dll
09/23/2005  06:56 AM             6,144 Microsoft.Data.ConnectionUI.dll

Sorry the data is so long. I cant paste in it.

Why is it not shows desktop directories and their files.
What did I do wrong? Any code or suggestion will be appreciated.

Thanks in advance

  • 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-24T22:09:56+00:00Added an answer on May 24, 2026 at 10:09 pm

    This is because your working directory is set to the application’s directory when you call Process.Start.

    Use the overload of Process.Start which accepts a ProccessStartInfo, then set the WorkingDirectory to the path of the batch file.

    http://msdn.microsoft.com/en-us/library/0w4h05yb.aspx

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

Sidebar

Related Questions

I am new to makefiles and facing some issue with it. I have created
After installing the new server, I am facing an issue. I have lot of
I seem to be facing a strange issue in SQL 2008. I have a
I am facing an issue while implementing MVC. I created a UIView subclass and
I am facing an issue with this simple jQuery code. I have attached the
I am facing strange issue on Windows CE: Running 3 EXEs 1)First exe doing
I have a public facing website that has been receiving a number of SQL
I am facing an issue where my Rails application is set to cache classes
I am facing an issue while executing queries.I use the same resultSet and statement
My development team of four people has been facing this issue for some time

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.