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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:05:00+00:00 2026-05-10T23:05:00+00:00

I have a service that sometimes calls a batch file. The batch file takes

  • 0

I have a service that sometimes calls a batch file. The batch file takes 5-10 seconds to execute:

System.Diagnostics.Process proc = new System.Diagnostics.Process(); // Declare New Process     proc.StartInfo.FileName = fileName;     proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;     proc.StartInfo.CreateNoWindow = true;     proc.Start();     proc.WaitForExit(); 

The file does exist and the code works when I run the same code in-console. However when it runs inside the service, it hangs up at WaitForExit(). I have to kill the batch file from the Process in order to continue. (I am certain the file exists, as I can see it in the processes list.)

How can I fix this hang-up?

Update #1:

Kevin’s code allows me to get output. One of my batch files is still hanging.

‘C:\EnterpriseDB\Postgres\8.3\bin\pg_dump.exe’ -i -h localhost -p 5432 -U postgres -F p -a -D -v -f ‘c:\backupcasecocher\backupdateevent2008.sql’ -t ‘\’public\’.\’dateevent\” ‘DbTest’

The other batch file is:

‘C:\EnterpriseDB\Postgres\8.3\bin\vacuumdb.exe’ -U postgres -d DbTest

I have checked the path and the postgresql path is fine. The output directory does exist and still works outside the service. Any ideas?

Update #2:

Instead of the path of the batch file, I wrote the ‘C:\EnterpriseDB\Postgres\8.3\bin\pg_dump.exe’ for the proc.StartInfo.FileName and added all parameters to proc.StartInfo.Arguments. The results are unchanged, but I see the pg_dump.exe in the process window. Again this only happens inside the service.

Update #3:

I have run the service with a user in the administrator group, to no avail. I restored null for the service’s username and password

Update #4:

I created a simple service to write a trace in the event log and execute a batch file that contains ‘dir’ in it. It will now hang at proc.Start(); – I tried changing the Account from LocalSystem to User and I set the admnistrator user and password, still nothing.

  • 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. 2026-05-10T23:05:01+00:00Added an answer on May 10, 2026 at 11:05 pm

    Here is what i use to execute batch files:

    proc.StartInfo.FileName                 = target; proc.StartInfo.RedirectStandardError    = true; proc.StartInfo.RedirectStandardOutput   = true; proc.StartInfo.UseShellExecute          = false;  proc.Start();  proc.WaitForExit     (         (timeout <= 0)             ? int.MaxValue : timeout * NO_MILLISECONDS_IN_A_SECOND *                 NO_SECONDS_IN_A_MINUTE     );  errorMessage = proc.StandardError.ReadToEnd(); proc.WaitForExit();  outputMessage = proc.StandardOutput.ReadToEnd(); proc.WaitForExit(); 

    I don’t know if that will do the trick for you, but I don’t have the problem of it hanging.

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

Sidebar

Ask A Question

Stats

  • Questions 113k
  • Answers 113k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After reading Domain Driven Design (Evans) it would seem that… May 11, 2026 at 10:01 pm
  • Editorial Team
    Editorial Team added an answer There is default-frame-alist variable that allows you to specify the… May 11, 2026 at 10:01 pm
  • Editorial Team
    Editorial Team added an answer Open-dbExpress for dbExpress driver for ODBC and refer to this… May 11, 2026 at 10:01 pm

Related Questions

I have a 3-tier .NET service app, which follows the standard approach: Frontend ->
I'm working on an application that is supposed to create products (like shipping insurance
I have an importer process which is running as a windows service (debug mode
I'm developing a SOAP application that integrates with a 3rd party. I think the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.