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.

Is it possible, when opening an cmd from the W7 program search bar on the start menu, to pass across another line for it to run when it opens?

Specifically what I'm trying to do is run cmd iisreset, as issreset isn't set to run as admin by default, but cmd is, so when I run it via cmd it runs as admin. Currently I have to go cmd -> Enter -> iisreset -> Enter

I know I could change iisreset to always run in admin too (and probably will), but just wondering if there's any way of doing the above in just one command from the start menu? (Save setting up batch scripts etc, as I may want to call other exes from cmd in the same way)

share|improve this question

1 Answer 1

up vote 3 down vote accepted
  1. Type cmd /K iisreset.
    enter image description here

  2. Press Ctrl+Shift+Enter


Result

Executing the steps describes above, will execute iisreset and drop you right into the administrative shell (that was used for the execution) afterwards.

enter image description here

Additional Information

Here is the command line documentation for cmd.exe. I highlighted the two command line options most relevant to this process.

Starts a new instance of the Windows command interpreter

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]    

/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains

/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
/A      Causes the output of internal commands to a pipe or file to be ANSI
/U      Causes the output of internal commands to a pipe or file to be
        Unicode
/T:fg   Sets the foreground/background colors (see COLOR /? for more info)
/E:ON   Enable command extensions (see below)
/E:OFF  Disable command extensions (see below)
/F:ON   Enable file and directory name completion characters (see below)
/F:OFF  Disable file and directory name completion characters (see below)
/V:ON   Enable delayed environment variable expansion using ! as the
        delimiter. For example, /V:ON would allow !var! to expand the
        variable var at execution time.  The var syntax expands variables
        at input time, which is quite a different thing when inside of a FOR
        loop.
/V:OFF  Disable delayed environment expansion.
share|improve this answer
    
Brilliant! Thanks, knew there must have been an easy way :) –  Psytronic May 21 '12 at 11: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.