Start new cmd.exe and NOT inherit environment?

Anders’ recipe has detailed control over a new environment, and I’m leaving that as the accepted answer because of that depth control. However one phrase in that answer led to me the method I’ll actually be using for the particular problem which prompted this enquiry. An “environment that is equal to the initial explorer.exe environment”. Oh! I know how to do that!

start /i "%windir%\explorer.exe" "%windir%\system32\cmd.exe"

Note: originally this was simply start /i explorer ..., but it turns out that doesn’t work reliably, and a full path should be be used for both parts. If all you need is a solution, you have everything now and can ignore the rest.


Following Ander’s comment below about a security warning I tested on 4 Win7 computers, a mix of Pro, Home, and Enterprise, 32 and 64bit. I fiddled with User Account Control, all the way up and all the way down. Also tested with a non-administrator Command Prompt shell. These all worked without error or warning.

On Server 2003, logged on as local administrator, I get a popup dialog “File Download – Security Warning: do you want to run or save this file?” with buttons for run,save, and cancel. Pressing [run] results in an additional dialog, “Windows Explorer – Security Warning: the publisher could not be verified. Are you sure you want to run this software?”. Pressing [run] again finally results in a usable command shell. Apparently there is some weird logic that results in Internet Explorer being substituted for Windows Explorer without the full path to the exe.

It gets even stranger though: using start with a title, (some advise to always include a title) results in the security warnings regardless of full path. Other parameters like starting directory seem to be okay.

:: security warning
start "clean shell" /i "%windir%\explorer.exe" "%windir%\system32\cmd.exe"

:: is okay
start /i  /d x:\ "%windir%\explorer.exe" "%windir%\system32\cmd.exe"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)