Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
How do I create a Windows Batch file that does not show the Command Prompt when executed?

I want to create a shortcut on my taskbar that sets an environment variable and then launches a program. Currently my shortcut goes to a .bat file with these lines:

set RESGENTOOLARCHITECTURE=Managed32Bit
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

but that leaves a CMD window open for the duration of the program that's launched (in this case Visual Studio). Is there a way I can do this without a CMD window opening or at least without it staying open?

I don't want to set the environment variable on my machine generally, just when I run this program.

thanks!

share|improve this question

marked as duplicate by Hello71, Nifle, Sathya Jul 12 '11 at 4:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
Not an exact duplicate question, but the answer is the same. –  Hello71 Jul 11 '11 at 17:02
add comment

2 Answers

up vote 0 down vote accepted

The linked answer is right, that you can't using batch files.

I would create a batch file that runs a PowerShell script (PowerShell is here to stay at least for the foreseeable future). Here is the batch file:

set RESGENTOOLARCHITECTURE=Managed32Bit
powershell c:\temp\OpenVisualStudio.ps1

And here is the contents of your PS1 PowerShell script file:

start-process "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe

Name then whatever you want, but I would name them the same (extension excepted), and put them in the same place. I wanted to combine them into one file, but it was problematic to set the variable.

I tested this, although I used it to open Word 2010.

share|improve this answer
add comment

How to run a bat file without displaying the command window:

Create a new file named 'runhidden.vbs' Edit it with a text editor and insert the following line:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

Set your shortcut to execute this:

wscript.exe runhidden.vbs yourbatfile.bat

Naturally, path names should be added to runhidden.vbs and yourbatfile.bat if required. This will execute yourbatfile.bat without showing the command window.

EDIT: To clarify "runhidden" is an entirely arbitrary name. You can name it how you want.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.