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.

Just discovered doskey emacs=emacs -nw $*, but without something like .bashrc, I'll have to type that every time I start a shell, right?

share|improve this question

migrated from stackoverflow.com May 23 '10 at 11:10

This question came from our site for professional and enthusiast programmers.

This question isn't identical, but the answer covers your scenario. –  Marcelo Cantos May 23 '10 at 10:51

3 Answers 3

This is a very good question. I found this. I suppose you could make a cmd script and have it run when starting cmd :-?

; Run a command when CMD.exe starts
[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor]

EDIT: I just tried it. I have AutoRun=C:\mini\bashrc.cmd and bashrc.cmd is

@echo off
set TEST_VAR=something

when I start cmd and enter echo %TEST_VAR% it says something. So it works :)

share|improve this answer
Small snippet I use: doskey∙♦=exit (where is [char]4). Enables you to close the shell with Ctrl+D, Enter. –  Joey May 23 '10 at 12:13
@Johannes Rössel Nice one, thanks :-) –  nc3b May 23 '10 at 12:19
This work great, nice job nc3b. –  Robert S Ciaccio Jul 28 '10 at 3:57
HKEY_CURRENT_USER\Software\Microsoft\Command Processor with AutoRun=%HOMEPATH%\bashrc.bat So every user would have his own startup-sequence –  bambam2174 Jul 18 '13 at 8:29
I must be an idiot but where do I put this code? –  Marcel Oct 10 '14 at 23:46

You can create a shortcut to cmd.exe and add the /k switch to run a certain .bat file on startup, something like this:

cmd.exe /k "%HOMEDRIVE%\%HOMEPATH%\cmd-startup.bat"

cmd-startup.bat in your home dir would then work just like .bashrc

share|improve this answer

EDIT: Found this: http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx

To expound on Martin's solution (the shortcut), here's the PowerShell equivalent.

NOTE: You will need to have PowerShell script execution enabled. If this is disabled, you'll need to run an elevated PowerShell and execute Set-ExecutionPolicy Unrestricted. Obviously, this is not recommended for security reasons, but there ya go.

powershell.exe -noexit -File "%HOMEDRIVE%\%HOMEPATH%\ps-startup.ps1"

Have a file named ps-startup.ps1 in your user directory and your shortcut will execute it as a PowerShell file on startup. Just run PowerShell with this shortcut from here on out.

share|improve this answer

Your Answer


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