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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:42:44+00:00 2026-06-08T23:42:44+00:00

I am trying to run cmd command in windows application in C#. My code

  • 0

I am trying to run cmd command in windows application in C#. My code is,

    progressBar1.Show();
    progressBar1.Minimum = 0;
    progressBar1.Maximum = 100;
    progressBar1.Step = 1;

    ProcessStartInfo ProcessInfo; 
    Process Process;

    for (int i = 0; i < 300000; i++)
    {
        progressBar1.PerformStep();
        int percent = (int)(((double)progressBar1.Value/(double)progressBar1.Maximum) * 100);
        progressBar1.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial",(float)7.02,FontStyle.Regular),Brushes.Black, new Point(progressBar1.Width / 2 - 10, progressBar1.Height / 2 -7));

        ProcessInfo = new ProcessStartInfo(command);
        ProcessInfo.RedirectStandardOutput = true;
        ProcessInfo.CreateNoWindow = true;
        ProcessInfo.UseShellExecute = false;

        Process = Process.Start(ProcessInfo);                    

        Process.Close();                    
    }
    progressBar1.Hide();                

Problem is, if I run the command in command promt; it installs the driver in couple of second but if I run the command in C# it doesn’t work.

Can anyone explain me, is there any code I am missing or not?

command is

ExecuteCommand("\"C:\\Disk1.Win7\\setup.exe\" /s /f1\"C:\\Disk1.Win7\\setup_install.iss\" /a\"C:\\Disk1.Win7\\OposData.reg\""); 
  • 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-06-08T23:42:46+00:00Added an answer on June 8, 2026 at 11:42 pm

    Consider moving the code for running your COMAMND,

    ProcessInfo = new ProcessStartInfo(command);
        ProcessInfo.RedirectStandardOutput = true;
        ProcessInfo.CreateNoWindow = true;
        ProcessInfo.UseShellExecute = false;
    
        Process = Process.Start(ProcessInfo);                    
    
        Process.Close(); 
    

    Outside of that “for” loop. Adding a WHILE loop which runs the driver installer, with the for loop embedded within it.

    This may solve your problem. You’re on the right track, just consider aligning things a little differently. As Alvin and a few others stated, your COMMAND is only being processed for 3ms, before it is shut down, and started again; to a maximum of 300000 times. Things just need to be moved around.

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

Sidebar

Related Questions

I am trying to run a cmd command with the following code: ProcessStartInfo cmd
I'm trying to run a cmd command in my wince7 machine. my code is:
I'm trying to run commands straight through the CMD on Windows (Terminal on Linux).
I am trying to run a command-line command from inside my Delphi application. ShellExecute(Form1.Handle,
I'm trying to invoke a native Windows command from Cygwin using run , but
I am trying to write javascript which should run cmd.exe with a specified command
Trying to run the following command in php to run powershell command... the following
Trying to run Jison unit tests, but the command fails. How do I fix
I am trying to run a console C++ application linking with my DLL files
I am trying to log the output from cmd tree command using ant with

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.