none
How to permanently configure VC command line tools?

    Question

  • Hi

    I'd like to permanently configure VC command line tools so that every program could use these tools without manually running vcvarsall.bat
    Is there any way to accomplish this?
    Particularly I need this for gui programs (cmake in my case). How can I set environment for gui programs?
    Saturday, April 18, 2009 4:34 PM

All replies

  • Vsvarsall.bat just sets environment variables.  Why don't you just put these into your system environment so whatever program you run has them set?  Control Panel + System, Advanced tab, Environment variables.  Other than that, surely any build tool can set environment variables or run .cmd files.  Ask specific CMake questions at their support channels.
    Hans Passant.
    • Proposed as answer by chitown8158 Sunday, April 19, 2009 5:25 AM
    Saturday, April 18, 2009 5:43 PM
  • Thanks for info.

    vcvarsall.bat runs one of 6 different bat files and has some logic in it. It's not just a list of SET commands so there's no way to replace it by just setting some environment variables in the control panel.
    I'd like to run it and make it somehow export all variables it sets so all future invocations of cmd.exe has access to these environment variables.
    It would be good to be able to reverse its effects as well :)
    • Proposed as answer by chitown8158 Sunday, April 19, 2009 5:25 AM
    Saturday, April 18, 2009 6:24 PM
  • Why can't your custom build system run vsvarsall.bat?
    Hans Passant.
    Saturday, April 18, 2009 7:10 PM
  • Because I run it directly from Start/Programs and not from command line.
    Saturday, April 18, 2009 7:52 PM
  • One thing build systems, like CMake, are very good at is running commands.  Have you figured out yet how to make CMake run commands?
    Hans Passant.
    Saturday, April 18, 2009 9:17 PM
  • Isn't it possible to create variables for cmake that specifies the directories for each tool? In other words, why not provide the complete path for the compiler and such?
    Sam Hobbs; see my SimpleSamples.Info
    Saturday, April 18, 2009 10:05 PM
  • That's not a good solution. Going this way I would need to change build scripts of every software package with cmake build system which needs VC command line tools.
    Making it the other way around I have to do only one change to my local system.
    I think you agree that's much better.
    • Proposed as answer by chitown8158 Sunday, April 19, 2009 5:25 AM
    Saturday, April 18, 2009 10:41 PM
  • I think the most universal and pretty solid way of communication between build system and VC are environment variables. That's why they are necessary for cmake to find VC command line tools.
    Saturday, April 18, 2009 10:44 PM
  • Your requirements are vague so it is likely that suggestions will not be useful.

    You ask how to "permanently configure VC command line tools". VC command line tools don't work in any way relevant to your question other than how other command line tools do. I don't know what cbuild is; it is not part of VS or is it? Do you know how this problem is solved in other systems that cbuild is used in?

    I don't understand why you say that environment variables are the best solution yet Hans's suggestions use environment variables yet you don't use Hans's suggestions.
    Sam Hobbs; see my SimpleSamples.Info
    • Proposed as answer by chitown8158 Sunday, April 19, 2009 5:25 AM
    Sunday, April 19, 2009 12:06 AM
  • It's CMake (www.cmake.org) not cbuild.
    It's open source, cross-platform build system.

    What Hans suggested is to change environment variables once and for ever :)
    While this works I would like to have something more dynamic than what Hans suggested and at the same time more persistent than a standard bat file is :)

    What I need is a version of vsvarsall.bat using setx command instead of set command to make changes to environment variables persistent.
    That's easy as it requires only to change all @set commands to @setx commands in this bat file.

    This version would however require writing something like vsvarsall-revert.bat which would revert all changes made by modified version of vsvarsall.bat.


    Sunday, April 19, 2009 3:58 PM
  • Okay, so there are simple solutions; just not as simple as you want.

    You still have not said if you have determined what the Linux equivalent would be.

    There are many possible solutions. Another possibility is to write a program that creates and environment and then uses that environment in a CreateProcess that executes CMake.

    CMake is not part of VS and neither is setx, so the answer to your question seems to be outside the scope of this forum. There seems to be nothing provided by VC that you can use or that you want to use.
    Sam Hobbs; see my SimpleSamples.Info
    Monday, April 20, 2009 3:14 AM
  • You still have not said if you have determined what the Linux equivalent would be.
    Linux equivalent of what?

    There are many possible solutions. Another possibility is to write a program that creates and environment and then uses that environment in a CreateProcess that executes CMake.
    Yes.

    CMake is not part of VS and neither is setx, so the answer to your question seems to be outside the scope of this forum.
    Question about configuring VC is outside the scope of " Visual C++ General " forum...
    I don't think so :)

    To sum up;
    Thanks nobugz and Simple Samples for your help.
    Now, I know how to do what I asked about in this topic.

    I think MS should provide persistent version of vsvarsall.bat and a way to revert changes made by this additional version. Of course it's easier for MS to let users find and create solution for this and other problems on their own, spending their own time and money.
    Monday, April 20, 2009 10:52 AM
  • Linux equivalent of what?


    Linux equivalent of what you are doing. In other words, if you were doing the same thing except in Linux instead of Windows then how would that be done? How would you solve the problem of providing the location of the Linux C++ compiler and other tools?
    Sam Hobbs; see my SimpleSamples.Info
    Monday, April 20, 2009 11:03 AM
  • I have the same question before. and I get up with a very handy solution.
    Just copy the vsvars32.bat in %VS90COMNTOOLS% to a .bat file and add one line at the end of it:
    @%SystemRoot%\system32\cmd.exe
    place the .bat file in a proper place. You can double click it everytime you want to do command line task with visual studio express
    I hope my reply can help.
    Monday, September 14, 2009 10:40 AM