Command line to "Close Control Panel Applet"?

EssKayKay

New member
Local time
9:37 AM
Messages
14
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

Computer type
PC/Desktop
OS
Win7 64-bit
Enter taskkill /? from a Elevated Command prompt. That is one way.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
I tried that to no avail, but maybe my syntax is bad --

control taskkill /F /IM mmsys.cpl
 

My Computer

Computer type
PC/Desktop
OS
Win7 64-bit
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

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Excellent - thank you very much Pyprohly. The batchfile is exactly what I was looking for - works perfectly.

Thanks again....
SKK
 

My Computer

Computer type
PC/Desktop
OS
Win7 64-bit
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

Computer type
PC/Desktop
OS
Windows 7 Ultimate 32-bit
Back
Top