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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:37:55+00:00 2026-05-27T17:37:55+00:00

I am using the system() command in C to execute commands like sc query

  • 0

I am using the system() command in C to execute commands like sc query mysql or net start mysql.

If the parameter is null pointer then it returns 1 if the cmd processor is OK, otherwise it returns 0. On successful command execution it returns 0.

My question is: Can I get a list of its return values? Like what it will return if the command is invalid or what the return value on unsuccessful execution will be? I want to do different things depending on the return value of system().

  • 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-27T17:37:55+00:00Added an answer on May 27, 2026 at 5:37 pm

    As the docs
    state system() return -1 if creating the new process for the command to be executed fails, otherwise it returns the exit code of the command executed. this is the same value you can retrieve using echo $? in unix or echo %ERRORLEVEL% in windows after executing the same command in a shell. So if you want to handle the return values you have to look at what the commands executed return.

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

Sidebar

Related Questions

In Perl, you can execute system commands using system() or `` (backticks). You can
I'm trying to start the del command using System.Diagnostic.Process. Basically I want to delete
You can easily use exec() or shell_exec() to execute a system command, like ls
I am familiar with using the os.system to run from the command line. However,
I am using /bin/tcsh as my default shell. However, the tcsh style command os.system('setenv
Operating System: OSX Method: From the command line, so using sed, cut, gawk, although
I want my ASP.NET page to shell out and execute git commands. I put
I would like to execute an OS command from my ruby script but I
I have a method I am using to execute a command on the local
I would like to restore my database in MySQL. When I try manually using

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.