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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:31:02+00:00 2026-05-11T02:31:02+00:00

Is it possible to make a batch file which can make a persistent change

  • 0

Is it possible to make a batch file which can make a persistent change to an environment variable?

For example my installer.bat script copies some files to a random location in the computer’s file-system. I’d like to add that location to the PATH environment variable so that the programs can be run in the current session.

FYI – the stuff I am installing changes very frequently: I want to do a fresh install every single time I run the program. Also, I do not want to over-write other previously installed copies of the program just in case some other (older) instance is still executing.

I’d like to be able to do something like this:

rem install_and_run.bat install.bat  myapplication.exe  

Unfortunately this does not work, because the install.bat never ‘returns’ to the main-script. myapplication.exe is never called. Next I tried:

cmd /C install.bat myapplication.exe  

Unfortunately this does not work because it means that install.bat is run in an entirely seperate cmd.exe shell. That means none of the environment variable changes persist once the script terminates because the cmd.exe also terminates.

There must be a way to make a batch-file which changes environment variables

Any suggestions?

  • 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-11T02:31:02+00:00Added an answer on May 11, 2026 at 2:31 am

    In your case, what you want is

    rem install_and_run.bat call install.bat  myapplication.exe 

    That is, use call to call install.bat, so that control will return to install_and_run.bat.

    I think you don’t understand that environment variables are per-process. Your batch file is running in an instance of cmd.exe, and that instance has an environment. When you wrote cmd /C you were creating a new instance of cmd.exe, which has its own environment. Then install.bat was making a ‘persistent’ change to the environment of the new instance of cmd.exe.

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

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • 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 The console class handles the thread synchronization for you. From… May 11, 2026 at 11:31 pm
  • Editorial Team
    Editorial Team added an answer This might be oversimplifying things, but why not just do:… May 11, 2026 at 11:30 pm
  • Editorial Team
    Editorial Team added an answer you can wrap your outgoing response using HttpServletResponseWrapper: class GetStatusWrapper… May 11, 2026 at 11:30 pm

Related Questions

I'm using a native DLL (FastImage.dll) in a C# ASP.NET Web Service that sometimes
Is there an easy way, preferably with a scripting language or a small tool
Is it possible to change the Windows command prompt working directory via Python script?
I have a very large (~6GB) SVN repository, for which I've written a batch

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.