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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:58:08+00:00 2026-05-17T21:58:08+00:00

I am attempting to create a shortcut that will load the vcvarsall.bat (Visual Studio

  • 0

I am attempting to create a shortcut that will load the vcvarsall.bat (Visual Studio Command prompt) under a runas command. Specifically, I want a shortcut that starts in a specific folder; has the runas network credential set to a domain account; mains local account affinity; and has msbuild environment variables set correctly.

Background: We have team city build agents that are not on the domain. Occasionally, I need to troubleshoot them. This means running the build under the team city local account, getting from source using the domain account. I also have the same scenario when working from home – my home computer is not on the domain.

I can use runas.exe to get the credentials correct, but I don’t get the msbuild environment variables.

%SystemRoot%\system32\runas.exe /netonly /user:domain\teamcityagent "%comspec% /k 

If I load the environment variables as per the shortcut and set the start in folder, I get the environment variables and working folder, but I have to enter my credentials each tfs command.

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86

How can I combine these two into one shortcut? What are the command quoting rules that apply here? Can you concatenate commands in a shortcut? It would be coolest to do this without a batch file, but if I have to fall back on a batch file, I’ll do that.

  • 1 1 Answer
  • 2 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-17T21:58:08+00:00Added an answer on May 17, 2026 at 9:58 pm

    You can execute multiple separate commands using &&. Successive commands will only be executed if the previous one succeeds (i.e., errorlevel 0). If you want to force all commands to execute, just use a single &.

    e.g., printing “foo” and “bar” then pause

    %comspec% /c echo foo && echo bar && pause
    

    However in your case, when using runas, you need to wrap the entire command and command arguments in double quotes. Any double quotes in the arguments need to be escaped by a backslash. Other backslashes should be interpreted correctly without needing escaping. To run as another user with the variables loaded printing a greeting, you can do the following:

    %SystemRoot%\system32\runas.exe /netonly /user:domain\teamcityagent "%comspec% /k \"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat\" x86 && echo Hello %USERDOMAIN%\%USERNAME%"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create an inbound Mule endpoint that will receive Syslog messages
So I am attempting to create a search field that will filter contacts on
In attempting to create an initial, failing unit test in Visual Studio Professonal 2008's
I'm attempting to create an xquery expression that will return selected nodes but will
When attempting to create an Azure project in Visual Studio 2010 I get a
I am attempting to create a Scala method that will take one parent group
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a CustomControl which will have various properties affected by an
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to create a Parcelable class in Android so that I can pass

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.