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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:39:50+00:00 2026-06-06T08:39:50+00:00

I have a C# console executable started within a DOS command process. I need

  • 0

I have a C# console executable started within a DOS command process.

I need to be able to execute DOS commands from the C# executable (specifically I need to be able to SET variables) and have the variables persist such that the rest of the DOS process can reference them.

ie:

Start DOS process
-> C# executes a SET command to set UserVariable
-> DOS process can ECHO %UserVariable%

Due to performance reasons I cannot write the set command to a dos script. In fact, I cannot have any file I/O at all.

Can anyone help?

  • 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-06T08:39:51+00:00Added an answer on June 6, 2026 at 8:39 am

    If you are running a C# app from a dos script and wishing to use variables set in the app afterwards from the script, I don’t know how to do that for just the context of that script from within C#, the other answers here show you for the machine itself but I appreciate you need something with a less permanent scope.

    A meta-programming workaround this could be to:

    • Call the C# app from a DOS FOR loop
    • From the C# app, output to the console SET commands
    • Use the for loop to execute the app output

    The calling DOS script would look like this:

    FOR /F "tokens=* delims=" %%A IN ('MyApp.exe') DO ( 
       %%A
    )
    

    The Console output from MyApp.exe would need to be in the form:

    SET UserVariable1=UserValue1
    SET UserVariable2=UserValue2
    

    And then each of the output lines would be executed by the calling FOR loop and the variables would then exist in the context of the calling script.

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

Sidebar

Related Questions

I have console application. In that i have some process that fetch the data
I have a console application that uses a number of command line switches to
I have some console.log commands spread through my site. Is it possible to override
I have a console app that performs a lengthy process. I am printing out
I have an executable that I need to run some tests on in C++
Supose you have a command line executable that receives arguments. This executalbe is widechar
I want to set the embedded icon for my executable console program to a
I have a command line winforms executable that calls into a Windows winforms application.
I have a VC++ console app and I need to check to see if
i have an executable program (.exe) writen in c++ and run on windows console

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.