Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to run a .bat file as a different user to troubleshoot a rights problem which I suspect.

For normal .exe files, you can Shift-right-click to get "Run as...". However, for a .bat file, this does not work (Shift-right-click gives no menu entry "Run as..."). Why is that so, and how can I "Run as" a .bat file? Is it possible at all?

System is Windows XP SP2 Home Edition.

share|improve this question

2 Answers

up vote 15 down vote accepted

Use the command line. For example,

runas /noprofile /user:COMPUTERNAME\USERNAME "C:\MYBAT.bat"

See more about the command in the reference documentation for Runas.

share|improve this answer
1  
At least in WinXP, this also works in the Run box. – pcapademic Feb 7 '10 at 20:22

To add the Run as... option for .BAT files to the context menu, use the following REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\batfile\shell\runas\command]
@="\"%1\" %*"

Copy the above contents to Notepad, and save the file with .REG extension (say, bat_runas.reg). Right-click the .REG file and choose Merge.

To add the Run as... menu for .CMD files, use this REG file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\cmdfile\shell\runas\command]
@="\"%1\" %*"

Copy the above contents to Notepad, and save the file with .REG extension (say, cmd_runas.reg). Right-click the .REG file and choose Merge.

share|improve this answer
Nifty :-). Any idea why this is not the default? – sleske Feb 8 '10 at 15:56
@sleske - This was default in WIndows 2000. It had been removed in XP (and later) for security reasons. added another registry 'hack' to add Run as for CMD files. – Molly7244 Feb 8 '10 at 16:03
@Molly: Thanks. Still I don't get the "security reasons". I can always "Run as" cmd.exe and then run my .bat, that would be the same, wouldn't it? So where's the security problem? – sleske Feb 9 '10 at 0:41
1  
@sleske - sometimes they call it 'User Anxiety', which was the reason for removing the summary from the status bar in Windows 7 when you select a folder. get it? well, i don't ... :P – Molly7244 Feb 9 '10 at 0:47

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.