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.

(using WinXP)

I've not written a batch file before. I want to create a shortcut for using virtuelenv. I normally have to open a shell, type C:\some-path-to-my-env\Script\activate.bat. Then I have a shell with the correct environment. I want to make a batch file that when clicked, opens a shell and does all that for me, so that I can have a usable shell with the env pre-loaded.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can do this as a shortcut to cmd.exe /K "C:\some-path-to-my-env\Script\activate.bat" where cmd.exe opens a shell instance, /K instructs it to remain open after the command finishes, and the command itself is written in the " "'s after that.

share|improve this answer
    
thanks! BTW, how can I do multiple things like that (e.g. run the .bat file, and then cd into another directory)? –  orokusaki Dec 26 '10 at 20:57
    
You can do this with a separate batch file in which the commands are, just put them in there as you would type them to the shell, or simply with one long combined command in the " " part where the individual commands are separated with &. –  Felix Dombek Dec 26 '10 at 21:08
    
thanks. Is there a way to run another batch file in a batch file, and then run more commands? If I put cd some-dir, new line, some.bat, new line, cd some-other-dir, it doesn't run anything past the first bat file. –  orokusaki Dec 26 '10 at 21:53
    
try call some.bat .. this was some trial and error for me too –  Felix Dombek Dec 26 '10 at 22:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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