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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:50:42+00:00 2026-05-22T19:50:42+00:00

I would like to start the Apache service on my Windows 7 with the

  • 0

I would like to start the Apache service on my Windows 7 with the help of a batch program. That’s a really simple task, all I have to do is type this:

net start Apache2.2

then press Enter; BUT I must have admin rights to do so, otherwise I get some error messages like this:

System error 5 has occurred.

Access is denied.

It’s OK, but I would like to check the output of the “net start XY” command, and in case the output (or the response) contains the mentioned “Access is denied” string, then I would like to do some other things in another part of the batch program (output some custom error messages and stuff).
I tried to check the output with FIND command like this (IT DOESN’T WORK THE WAY IT SHOULD):

@echo off
set search_string=Access is denied
echo We are looking for this string: "%search_string%"
rem set errorlevel =
net start Apache2.2 | find /i "%search_string%" > nul
echo The errorlevel number is: "%ERRORLEVEL%"
if %ERRORLEVEL% EQU 0 goto gotcha
if %ERRORLEVEL% EQU 1 goto not_found
if %ERRORLEVEL% EQU 2 goto para

:gotcha
echo OK, found it
echo So maybe you don't have the rights to do so...
goto end

:not_found
echo String not found...
echo So this would mean there are no problems related to admin-rights... but YES, there are... :-S
goto end

:para
echo Something's not OK...
goto end

:end
echo -- END --
pause

Starting this batch program without admin rights, it outputs the mentioned “Access is denied”, so it should jump to “gotcha” label. Unfortunately it doesn’t work fine, it jumps to “not_found”, which means it didn’t find the given string (“Access is denied”).

Maybe the problem is that

net send XY

command sends the “Access is denied” output a little bit delayed, just after checking for admin rights, and find doesn’t take care about it anymore. But it’s just guessing, I don’t know the real explanation of the problem.

BUT the code above DOES work when I create another little batch program which just simply echoes the lines above with the “Access is denied” string. So the other little batch program, which shows that ‘find’ command can work the way it’s written like above, looks like this:

@echo off
echo.
echo System error 5 has occurred.
echo.
echo Access is denied. blabla
echo.

I saved this file with the name “write_accessdenied_stuff.bat”.

After that, I tried the code above, but instead of the “net send XY….” row I wrote this one:

write_accessdenied_stuff.bat | find /i "%search_string%" > nul

so the beginning of the code is changed like this, and IT WORKS:

@echo off
set search_string=Access is denied
echo We are looking for this string: "%search_string%"
write_accessdenied_stuff.bat | find /i "%search_string%" > nul
..........
..........

With this one, the find command sets the errorlevel to 0, which means it has found the string given, so the execution of the program jumps to “gotcha” label.

So how can I find the little bit delayed “Access is denied” output of the “net start XY” command?

Thank you very much 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-22T19:50:42+00:00Added an answer on May 22, 2026 at 7:50 pm

    Use

    net start Apache2.2 2>&1 | find /i "%search_string%" > nul
    

    in order to tie STDERR to the standard output.

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

Sidebar

Related Questions

(please excuse that I didn't use aliases). I would like my query output to
I would like to update my SQL lite database with the native update-method of
I would like to get a sum from a column, with and without a
I would like to remove/delete a migration file. How would I go about doing
I want to have generalised email templates. Currently I have multiple email templates with
My question is about memory use and objects in actionscript 2. If I have
I'm trying to write test harness for part of my Android mapping application. I
I want the messagebox to only show if the number is equal to 0.
There doesn't seem to be any tried and true set of best practices to
I know its probably possible, but is it practical and doable to try and

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.