Command line to "Close Control Panel Applet"?


  1. Posts : 14
    Win7 64-bit
       #1

    Command line to "Close Control Panel Applet"?


    Hello,

    I would like to know if there is a way to "close" an open Control Panel Applet via a command line reference?I know a couple ways to open the window -

    "c:\windows\system32\mmsys.cpl" OR command mmsys.cpl

    but I would like to also close it via command line. Any suggestions?

    Thanks,
    SKK
      My Computer


  2. Posts : 6,285
    Windows 10 Pro X64
       #2

    Enter taskkill /? from a Elevated Command prompt. That is one way.
      My Computer


  3. Posts : 14
    Win7 64-bit
    Thread Starter
       #3

    I tried that to no avail, but maybe my syntax is bad --

    control taskkill /F /IM mmsys.cpl
      My Computer


  4. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #4

    Ztruker said:
    Enter taskkill /? from a Elevated Command prompt. That is one way.
    That is one way.
    Code:
    taskkill /im rundll32.exe
    But it's not so safe if there happens to be other Rundll32 processes running.

    A safer method would be to use a bit of VBScript.


    CloseSound.vbs
    Code:
    Set objShell = CreateObject("WScript.Shell")
    objShell.AppActivate("Sound")
    objShell.SendKeys("%{F4}")
    CloseSound.bat
    Code:
    > "%TEMP%\tmp_%~n0.vbs" (
    	echo Set objShell = CreateObject^("WScript.Shell"^)
    	echo objShell.AppActivate^("Sound"^)
    	echo objShell.SendKeys^("%%{F4}"^)
    )
    WScript "%TEMP%\tmp_%~n0.vbs"
    del "%TEMP%\tmp_%~n0.vbs"
    
    REM Same as the above but on one line:
    (echo Set objShell = CreateObject^("WScript.Shell"^)&echo objShell.AppActivate^("Sound"^)&echo objShell.SendKeys^("%%{F4}"^))>"%TEMP%\tmp_%~n0.vbs"&&(WScript "%TEMP%\tmp_%~n0.vbs"&del "%TEMP%\tmp_%~n0.vbs")
    Command Line command
    Code:
    (echo Set objShell = CreateObject^("WScript.Shell"^)&echo objShell.AppActivate^("Sound"^)&echo objShell.SendKeys^("%{F4}"^))>"%TEMP%\tmp_CloseSound.vbs"&&(WScript "%TEMP%\tmp_CloseSound.vbs"&timeout 1 >NUL&del "%TEMP%\tmp_CloseSound.vbs")
    Note that these solutions make use of temp files.
      My Computer


  5. Posts : 14
    Win7 64-bit
    Thread Starter
       #5

    Excellent - thank you very much Pyprohly. The batchfile is exactly what I was looking for - works perfectly.

    Thanks again....
    SKK
      My Computer


  6. Posts : 1
    Windows 7 Ultimate 32-bit
       #6

    One other way is to search for the PID of the rundll32.exe instance that is running the mmsys.cpl module
    Code:
    tasklist /M mmsys.cpl /FI "IMAGENAME eq rundll32.exe"
    then you can safely kill the correct process using taskkill

    Code:
    taskkill /F /PID <pid>
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:56.
Find Us