batch file - Difference between running a command from cmd.exe or Windows Run -


i'm trying run application user , while works nicely in cmd.exe prompt, doesn't work if go windows run prompt (it depends on application i'm trying run).

for example, works fine both cmd.exe or w-run prompt (using either windows xp or windows 7):

runas /user:me regedit.exe 

while works in cmd.exe prompt (it ask password in both cases nothing after if launched w-run on either winxp or w7):

runas /user:me services.msc 

it's kind of inconsistent, cmd works windows run, it's unreliable , random.

any ideas there such difference? around problem, i'm using batch files launch applications user , type batch file full path in windows run prompt. ensure reliability still know if i'm doing wrong.

cmd /k "runas /user:me ""regedit.exe"" && exit" 

the "problem" runas

  • it needs command 1 argument, if running arguments have enclose command in quotes, , if command includes own quotes, need escaped.

  • it designed call .exe files (well, windows valid executable files).

this 2 options should handle program start

runas /user:me "cmd.exe /c \"start services.msc\"" runas /user:me "mmc.exe %systemroot%\system32\services.msc" 

in first case, using ability of cmd.exe find adecuated executable run .msc file. in second case, directly calls adecuated executable handle .msc file.

for batch files, instead of cmd /k .... & exit, can directly use cmd /c ... close console when command finishes.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -