I'd like to be able to alias a dos command to use in conjunction with the runas command
specifically I'm tired of getting the full path to BIDS ("C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
), and I'd like to alias like MS has done for ssms
.
Anyone know how to do this? I know I can accomplish this with a batch file, but I'd really rather not.
runas /user:user /netonly bids
vs.
runas /user:user /netonly "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
This doskey
technique is featured over at SuperUser, see https://superuser.com/questions/49170/create-an-alias-in-windows-xp.
The problem with it is that you can't define an alias to be used by runas
. You could define an alias that included both runas
and the command you want to run, but this would not then be reusable. But what about doing this:
SET BIDS=C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
DOSKEY r=runas /user:user /netonly "%$1%"
Which you can then use like
r bids
Of course this requires you to set an environment var for each shortcut you 'd like to have, but I think this is no greater requirement than setting the doskey
alias itself. In any case, it doesn't create a file and it doesn't require that anything be placed in the path
.
Update:
I didn't try it myself, but it certainly looks like you can set it and forget it.
DOSKEY
alias can be set each time cmd.exe
starts using the registry
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With