Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: 3 BAT files to switch between Speakers and Headset. The speeds vary. Why?  (Read 3433 times)

0 Members and 1 Guest are viewing this topic.

slack7639

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    I've put nircmd.exe in my Environment Variables / System Variables / Path

    Below are BAT files that switch between Speakers and Headset, 3 for each.

    I'm wondering why there is such a noticeable variance in the speed at which they execute.

    I can see why the second one is slower, it's the NirCmd console, but why is the 3rd one so slow?

    . . . there could be . . . at the beginning:  @ECHO OFF . . . at the end:  EXIT

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    . . . Three BAT files that switch to Speakers and Stereo Mix, fastest to slowest:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    START "" /B "nircmd.exe" setdefaultsounddevice "Desktop Speakers" 1
    START "" /B "nircmd.exe" setdefaultsounddevice "Desktop Speakers" 2

    START "" /B "nircmd.exe" setdefaultsounddevice "Stereo Mix Input" 1
    START "" /B "nircmd.exe" setdefaultsounddevice "Stereo Mix Input" 2

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    START "" /B "nircmdc.exe" setdefaultsounddevice "Desktop Speakers" 1
    START "" /B "nircmdc.exe" setdefaultsounddevice "Desktop Speakers" 2

    START "" /B "nircmdc.exe" setdefaultsounddevice "Stereo Mix Input" 1
    START "" /B "nircmdc.exe" setdefaultsounddevice "Stereo Mix Input" 2

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    nircmd.exe setdefaultsounddevice "Desktop Speakers" 1
    nircmd.exe setdefaultsounddevice "Desktop Speakers" 2

    nircmd.exe setdefaultsounddevice "Stereo Mix Input" 1
    nircmd.exe setdefaultsounddevice "Stereo Mix Input" 2

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    . . . Three BAT files that switch to Headset and Mic, fastest to slowest:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    START "" /B "nircmd.exe" setdefaultsounddevice "Logitech Headset" 1
    START "" /B "nircmd.exe" setdefaultsounddevice "Logitech Headset" 2

    START "" /B "nircmd.exe" setdefaultsounddevice "Logitech Mic" 1
    START "" /B "nircmd.exe" setdefaultsounddevice "Logitech Mic" 2

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    START "" /B "nircmdc.exe" setdefaultsounddevice "Logitech Headset" 1
    START "" /B "nircmdc.exe" setdefaultsounddevice "Logitech Headset" 2

    START "" /B "nircmdc.exe" setdefaultsounddevice "Logitech Mic" 1
    START "" /B "nircmdc.exe" setdefaultsounddevice "Logitech Mic" 2

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    nircmd.exe setdefaultsounddevice "Logitech Headset" 1
    nircmd.exe setdefaultsounddevice "Logitech Headset" 2

    nircmd.exe setdefaultsounddevice "Logitech Mic" 1
    nircmd.exe setdefaultsounddevice "Logitech Mic" 2

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    Salmon Trout

    • Guest
    When you use the START command, in a batch or from the prompt, like you have above, control returns at once. You are starting the program in a separate process, and it finishes some time later. When you run the program directly by name, as in your third example, you don't get control back until the program finishes, which explains the extra time. You can see the options available for START by typing START /? at the prompt.



    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    slack7639,
    Welcome to the forum. Is this your first  time?
    It can help if you would indicate what OS you are using and what kind of hardware you have. Batch file options can depend of the OS.

    Also, please explain this:
    Quote
    I've put nircmd.exe in my Environment Variables
    The nircmd.exe is about 15 years old and is the kind of thing that can be a hazard. It seems to have lost support by the author.
    Quote
    https://community.norton.com/en/forums/nircmd
    Dec 15, 2008 - 12 posts - ‎5 authors
    Of course a sharp knife is dangerous, but also useful as are many Nirsoft tools I use.Or do you believe the single spyware report that Google turns up? NIRCMD.EXE, Spyware RemoveNIRCMD.EXE, has been determined *B*, how to remove this Spyware threat. It's part of malware group Potentially harmful ...
    I did not say that, somebody else said it.  :(

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Geek every project he has worked on here is using Nircmd...i believe he's aware how old it is...
    " Anyone who goes to a psychiatrist should have his head examined. "

    Salmon Trout

    • Guest
    Also, please explain this:The nircmd.exe is about 15 years old and is the kind of thing that can be a hazard. It seems to have lost support by the author.I did not say that, somebody else said it.  :(

    A little knowledge can be a hazard, as the proverb says using slightly different words. I just downloaded 64 bit Nircmd version 2.81 released 23 May 2016, which is not exactly "fifteen years ago". The copyright message says (c) 2003 - 2016. I downloaded it from the author's website. New versions seem to come out about every 2 or 3 years. Maybe you should check things that "somebody else" said.


    Salmon Trout

    • Guest
    Another command-line utility, cmdow.exe, that can do some similar things to nircmd, regularly gets a slating because some antivirus apps flag it as a threat, mainly (I think) because it lets you run programs hidden, well, so does VBscript.

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    A little knowledge can be a hazard, as the proverb says using slightly different words. I just downloaded 64 bit Nircmd version 2.81 released 23 May 2016, which is not exactly "fifteen years ago". The copyright message says (c) 2003 - 2016. I downloaded it from the author's website. New versions seem to come out about every 2 or 3 years. Maybe you should check things that "somebody else" said.

    + 1.
    " Anyone who goes to a psychiatrist should have his head examined. "

    slack7639

      Topic Starter


      Rookie

      • Experience: Beginner
      • OS: Unknown
      3 BAT files to switch between Speakers and Headset. The speeds vary. Why?
      « Reply #7 on: April 17, 2018, 05:52:27 PM »
      . . . Welcome to the forum . . . first time?

      Thx!  No, I've posted here before.

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      . . . It can help if you would indicate what OS you are using and what kind of hardware you have. Batch file options can depend of the OS.

      It's an HP z240.  It's fast.  I like it!

      Operating System
      Windows 10 Pro 64-bit

      CPU
      Intel Core i7 6700 @ 3.40GHz
      Skylake 14nm Technology

      RAM
      16.0GB Dual-Channel Unknown @ 1063MHz (15-15-15-36)

      Motherboard
      HP 802F (CPU0)

      Graphics
      HP E272q (2560x1440@59Hz)
      Intel HD Graphics 530 (HP)

      Storage
      256GB Crucial_CT275MX300SSD1 (SSD)

      Optical Drives
      hp HLDS DVDRW GUD1N

      Audio
      Realtek High Definition Audio

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      . . . Also, please explain this:  I've put nircmd.exe in my Environment Variables

      I created this folder . . . C:\Windows\System32\USER-ADDED

      I put nircmd.exe and nircmdc.exe in it, then:

      Control Panel / System / Advanced system settings / Advanced tab - Environment Variables button at bottom

      . . . System variables / click on Path - Edit . . . I put this folder in the list:  C:\Windows\System32\USER-ADDED

      Then do a Restart, so it takes effect.

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      . . . The nircmd.exe is about 15 years old and is the kind of thing that can be a hazard. It seems to have lost support by the author.

      I think it's still going.  I use it for some other things, so it works, and I see this . . . NirBlog . . . http://blog.nirsoft.net/

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      . . . Nirsoft . . . Spyware threat. It's part of malware group Potentially harmful . . .

      Check out at all these programs - I think it's ok . . . http://www.nirsoft.net/

      Also, I used ShellExView a while back to get rid of some right-click item that was messing something up, and it worked . . . http://www.nirsoft.net/utils/shexview.html

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      slack7639

        Topic Starter


        Rookie

        • Experience: Beginner
        • OS: Unknown
        START nircmd.exe doesn't work in a BAT file with File Explorer. Why?
        « Reply #8 on: April 17, 2018, 06:00:10 PM »
        So now, how could this be explained:

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        This works to get File Explorer to open to View / Details (rather than the default):

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        START "" "C:\Windows\Explorer.exe" "C:\1"
        nircmd.exe wait 1000

        nircmd.exe sendkey alt press
        nircmd.exe sendkey v press

        nircmd.exe sendkey Esc press
        nircmd.exe sendkey Esc press

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        But if I put in the START (below), it opens to the "1" folder, but doesn't go to View / Details :-(
        1.) No change if I make it wait 2 seconds (2000)
        2.) No change if I get rid of /B
        3.) If I use nircmdc.exe, and put a PAUSE at the end, the DOS window doesn't show anything

        So, there's something different going on between the sound settings, and something like File Explorer.  Any idea what?

        In this case, the Environment Variable works, and using START does not.

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        START "" "C:\Windows\Explorer.exe" "C:\1"
        START "" /B "nircmd.exe" wait 1000

        START "" /B "nircmd.exe" sendkey alt press
        START "" /B "nircmd.exe" sendkey v press

        START "" /B "nircmd.exe" sendkey Esc press
        START "" /B "nircmd.exe" sendkey Esc press

        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        " Anyone who goes to a psychiatrist should have his head examined. "

        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        Quote
        . . . Also, please explain this:  I've put nircmd.exe in my Environment Variables

        I created this folder . . . C:\Windows\System32\USER-ADDED

        I put nircmd.exe and nircmdc.exe in it, then:

        Control Panel / System / Advanced system settings / Advanced tab - Environment Variables button at bottom

        . . . System variables / click on Path - Edit . . . I put this folder in the list:  C:\Windows\System32\USER-ADDED

        Then do a Restart, so it takes effect.

        Also why do it this way ? ?...Why not just add nircmd to the Path ? ?
        " Anyone who goes to a psychiatrist should have his head examined. "

        slack7639

          Topic Starter


          Rookie

          • Experience: Beginner
          • OS: Unknown
          Ok, you were saying NirCmd is ok.

          I thought that's how you do it.  All the other things in there are specifying folders, not a program . . . I thought that means, "look in these folders for the thing to run" . . . Am I wrong?

          slack7639

            Topic Starter


            Rookie

            • Experience: Beginner
            • OS: Unknown
            Oh, you're saying why not just put this path in there, in the System Variables:

            C:\Program Files (x86)\NirCmd

            idk . . . don't know how a computer really works . . . maybe it runs faster if it's in System32

            . . . I put it in System32 in a folder called "USER-ADDED" so I can keep track of what I'm doing, somewhat

            . . . don't know where I would find something that explains "how to" and "why"

            patio

            • Moderator


            • Genius
            • Maud' Dib
            • Thanked: 1769
              • Yes
            • Experience: Beginner
            • OS: Windows 7
            Correct.

            System32 should never be edited...even with an added folder as it's a system folder...

            Try it with your new changes...any difference ?
            " Anyone who goes to a psychiatrist should have his head examined. "

            slack7639

              Topic Starter


              Rookie

              • Experience: Beginner
              • OS: Unknown
              I put both of these Paths in System variables:

              C:\Program Files\NirCmd
              C:\Program Files (x86)\NirCmd

              . . . and tried it . . . if I use START in the bat file with NirCmd, to try and go to Details in File Explorer, it doesn't work.

              The following works.  Why would using START mess it up?

              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

              START "" "C:\Windows\Explorer.exe" "C:\1"
              nircmd.exe wait 1000

              nircmd.exe sendkey alt press
              nircmd.exe sendkey v press

              nircmd.exe sendkey Esc press
              nircmd.exe sendkey Esc press