How to control Windows system volume using JScript or VBScript?

前端 未结 7 657
说谎
说谎 2020-12-03 06:10

I want to control the volume of my Windows system from a JScript or VBScript script. Any ideas?

Also, can I unmute the system volume if it is muted?

7条回答
  •  鱼传尺愫
    2020-12-03 06:41

    I used nircmd.exe along with vbscript to control system volume.

    Set objShell = CreateObject("WScript.Shell") 
    If Not WScript.Arguments.Named.Exists("elevate") Then
      CreateObject("Shell.Application").ShellExecute WScript.FullName _
        , """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
      WScript.Quit
    End If
    objShell.Run("nircmd.exe setvolume 0 0 0") 
    
    'Set WshShell = WScript.CreateObject("WScript.Shell")
    'WshShell.Popup "Success", "5", "MuteSpeaker"
    
    ' to successfully run this vbscript during log-off, nircmd.exe during should be present in "C:\Windows\System32"
    ' [cscript //X scriptfile.vbs MyArg1 MyArg2]
    

提交回复
热议问题