VB icon

Windows 10 Taskbar sound icon failure

Email
Submitted on: 1/1/2019 7:32:44 PM
By: A_X_O 
Level: Beginner
User Rating: Unrated
Compatibility: VbScript (browser/client side)
Views: 1556
 
     Windows 10 often fails to open the Sound Volume Dialog when the Taskbar Sound Icon is clicked. Here is a quick solution to that problem.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Windows 10 Taskbar sound icon failure
' Description:Windows 10 often fails to open the Sound Volume Dialog when the Taskbar Sound Icon is clicked. Here is a quick solution to that problem.
' By: A_X_O
'**************************************

'
'------------------------------------------------------------------------------	'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'		Demonstration: Windows 10, VBScript; System Sound Volume	'
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	'
'										'
'	Purpose		:	Demonstrates VBScript Open SndVol.exe		'
'	-----------------------------------------------------------------------	'
'	Creation Date	: 	01/01/2019 [dd/mm/yyyy]				'
'	Version		:	1.1						'
'	Designer	:	Fabian						'
'										'
'##############################################################################	'
'			MODIFICATION HISTORY					'
'------------------------------------------------------------------------------	'
'	Version		:	1:0	01/01/2019	Create the Sample	'
'			:	1:1	02/01/2019	Cleanup Objects		'
'										'
'										'
'------------------------------------------------------------------------------	'		
'
Public Const PlatformError_L1 = "This application is not compatible with"			'Application Incompatibility Message
Public Const PlatformError_L2 = "your version of Windows."					'Application Incompatibility Message
Public Const PlatformError_L3 = "Compatibility Error"						'Application Incompatibility Message
'
Public strPlatform										'Example Windows Vista or Windows 10
Public intPlatformBit										'Example Windows 32 Bit or Windows 64 Bit
'
'							Data Types Named for complete clarity, but VBScript only 
'							makes use of the Variant, data type.										
'
Public strDriveLetter					'As String				'Store the root directory / Drive-Label
'
Public Const SW_SHOWNORMAL = 1									'Constant for sndvol Window [SW_ Show Window]
'
'
Public Const strTargetPath = "\sndvol.exe" 		'As String				'The application we are targeting
Public Const str32BitPath = "\Windows\System32"		'As String				'Determine correct location for 32Bit Windows
Public Const str64BitPath = "\Windows\SysWOW64"		'As String				'Determine correct location for 64Bit Windows
'
Dim objWMIService					'As Object				'Memory for Windows Management Instrumentation
Dim colSettings						'As Integer				'Memory for items in the Windows Address Width Column
Dim colOperatingSystems					'As String				'Memory for items in the Windows Version Column
Dim WshShell						'As Object				'Memory for Windows Script Host
'
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")	'Communication with the WMI
Set colSettings = objWMIService.ExecQuery ("SELECT * FROM Win32_Processor")			'Return the Address Width
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")	'Return the Windows Version
Set WshShell = Wscript.CreateObject("Wscript.Shell")						'Create the Windows Scripting Object
'
	strDriveLetter = Left((Wscript.ScriptFullName), 2) 					'Quick and easy way to get the Drive letter
'
For Each objOperatingSystem in colOperatingSystems						'Work through the list of Operating Systems
'
	strPlatform = objOperatingSystem.Version						'Store the Returned String
'
Next
'
For Each objProcessor In colSettings								'Work through the list Address Widths
'
	intPlatformBit = objProcessor.AddressWidth						'Store the Returned Integer
'
Next
'
Call Main()											'Begin
'
Public Sub Main()										'The first Sub-Routine
On Error Resume Next
'
If Left((strPlatform), 2) = 10 And intPlatformBit = 64 Then					'Check for 64Bit Windows 10
'
Call StartSoundVolumeApp("1064")								'Call appropriate routine for 64Bit Windows 10
'
ElseIf Left((strPlatform), 2) = 10 And intPlatformBit = 32 Then
'
Call StartSoundVolumeApp("1032")								'Call appropriate routine for 32Bit Windows 10
'
Else												'Invalid Platform: Notify user and Exit Script
'
	MsgBox PlatformError_L1 & VbCrLf & _
		PlatformError_L2, _
		VbSystemModal + VbExclamation + VbOkOnly, _
		PlatformError_L3
'
Call CleanupObjectInstances
'
	WScript.Quit										'End
'
Exit Sub
'
End If
'
End Sub
'
Public Sub StartSoundVolumeApp(ByVal WindowsVersion)						'Sub-Routine to build path and execute sndvol.exe
On Error Resume Next										'Override all errors
'
Dim SoundControlApp										'Memory for sndvol.exe path						
'
Select Case WindowsVersion									'Two possibilities available, so, determine the path for each
'
Case "1064"											'Windows 10 64Bit 
'
	SoundControlApp = (strDriveLetter & _
			str64BitPath & _
			strTargetPath)
'
	WshShell.Run SoundControlApp, SW_SHOWNORMAL, FALSE					'Run the sndvol.exe application in the \Windows\SysWOW64 directory
'
Call CleanupObjectInstances
'
Case "1032"											'Windows 10 32Bit 
'
	SoundControlApp = (strDriveLetter & _
			str32BitPath & _
			strTargetPath)
'
	WshShell.Run SoundControlApp, SW_SHOWNORMAL, FALSE					'Run the sndvol.exe application in the \Windows\System32 directory
'
Call CleanupObjectInstances
'
Case Else: Exit Sub										'Exit the routine in all other cases
'
Call CleanupObjectInstances
'
End Select
'
End Sub
'
Public Sub CleanupObjectInstances()								'Release the objects
On Error Resume Next
'
Set objWMIService = Nothing
Set colSettings = Nothing
Set colOperatingSystems = Nothing
Set WshShell = Nothing
'
End Sub
'


Other 18 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.