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

Author Topic: How to Control USB POrt (on/off) using batch file?  (Read 7970 times)

0 Members and 1 Guest are viewing this topic.

jik

    Topic Starter


    Rookie

    How to Control USB POrt (on/off) using batch file?
    « on: February 04, 2009, 03:17:25 AM »
    Is this possible to make a batch file(MSDOS) that will turn off and on the USB port?

    Ex.
    Unpluging a USB device = OFF
    PLUG = ON

    Thanks!

    Dias de verano

    • Guest
    Re: How to Control USB POrt (on/off) using batch file?
    « Reply #1 on: February 04, 2009, 03:22:06 AM »
    You can with a free software utility called Usbdeview. Or Microsoft Devcon. Either of of which you would have to download and install.



    jik

      Topic Starter


      Rookie

      Re: How to Control USB POrt (on/off) using batch file?
      « Reply #2 on: February 04, 2009, 04:36:06 AM »
      Thanks A LOT... I Got DEVCON... and it works.....

      Dias de verano

      • Guest
      Re: How to Control USB POrt (on/off) using batch file?
      « Reply #3 on: February 04, 2009, 04:38:43 AM »
      Thanks A LOT... I Got DEVCON... and it works.....


       :)

      Yay!!!

      Biker Steve



        Rookie

        Re: How to Control USB POrt (on/off) using batch file?
        « Reply #4 on: February 05, 2009, 08:31:57 AM »
        Consider changing your way of thinking on how to resolve your problem and use the MS DOS command "MOUNTVOL" as follows. In this example certain commands have been "remmed" out for safety.

        rem By using the "MOUNTVOL" command USB drives used as backup-to-disk targets
        rem can be either removed or plugged back in.
        rem By using the "NET SHARE" command USB drives may be shared out to users.

        c:
        cd C:\windows\system32\

        cls
        @echo.
        @echo.

        rem This command displays both the details of the corresponding Volume Names and Paths
        @echo on
        call mountvol.exe
        @echo off

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.

        rem These commands removes the "volume mount point" from the "specified directory"
        @echo on
        rem This commands removes the drive letter F: from the USB device name
        rem mountvol.exe F: /D
        rem This commands removes the drive letter G: from the USB device name
        rem mountvol.exe G: /D
        @echo off

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.

        rem This command displays both the details of the corresponding Volume Names and Paths
        @echo on
        call mountvol.exe
        @echo off

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.

        rem These commands assign the "volume mount point" to the "individual directory"
        rem Should you be required to use the "volume mount point" for different USB Drives
        rem You can mountvol different "individual directory" so long as there is only 1
        rem USB drive plugged in at once.
        @echo on
        rem mountvol.exe F: \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
        rem mountvol.exe F: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
        rem
        rem mountvol.exe G: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
        @echo off

        rem F:\ = \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
        rem G:\ = \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.

        rem This command displays both the details of the corresponding Volume Names and Paths
        @echo on
        call mountvol.exe
        @echo off

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.

        rem This command displays the available "shares"
        @echo on
        net share
        @echo off

        @echo.
        @echo.
        pause


        rem ***************
        cls
        @echo.
        @echo.

        rem This command stops sharing the available "shares"
        @echo on
        net share F /delete
        net share G /delete
        @echo off

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.
         
        rem This command shares out the USB directory drive with an assigned shared name
        @echo on
        net share F=F:
        net share G=G:
        @echo off

        @echo.
        @echo.
        pause

        rem ***************
        cls
        @echo.
        @echo.

        rem This command displays the available "shares"
        @echo on
        net share
        @echo off

        @echo.
        @echo. 
         
         

        jik

          Topic Starter


          Rookie

          Re: How to Control USB POrt (on/off) using batch file?
          « Reply #5 on: February 10, 2009, 02:36:51 AM »
          Thanks  ;D... But I'm reseting USB MODEM.... Thanks for the reply!!!

          BatchFileCommand



            Hopeful
          • Thanked: 1
            Re: How to Control USB POrt (on/off) using batch file?
            « Reply #6 on: February 10, 2009, 06:07:31 AM »
            Hey Biker Steve,

            Why do you have all those


            @echo or @echo. then cls.

            You just type @echo off and you don't need to have all those @'ts. Then you Just do @echo on to turn it back on again.
            οτη άβγαλτος μεταφ βαθμολογία

            Carbon Dudeoxide

            • Global Moderator

            • Mastermind
            • Thanked: 166
              • Yes
              • Yes
              • Yes
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 7
            Re: How to Control USB POrt (on/off) using batch file?
            « Reply #7 on: February 10, 2009, 06:26:51 AM »
            And what will this file be used for?

            Biker Steve



              Rookie

              Re: How to Control USB POrt (on/off) using batch file?
              « Reply #8 on: February 11, 2009, 04:51:36 AM »
              In answer to the question “And what will this file be used for?”,

              I am currently working on a solution to resolve the following issue. We have remote customers whom use USB hard drives to backup both their main file server and terminal server too. The terminal server is backed up to a USB hard drive which is attached too and shared out from the main file server. From time to time as the user rotates and exchanges the USB backup hard drives that are attached to the main file server the terminal server does not see the main file server newly attached shared out USB backup hard drive. It is our intention that each time a USB backup hard drive is attached to the main file server that it is both mounted and shared out by means of a MS DOS batch file that uses both the “mountvol”  and “net share” commands. The process is instigated from an “autorun.inf” file located on the root of each USB hard drive which in turn calls a MS DOS batch file which in turn calls the previously given example MS DOS batch file located on the main file server. I gave an example of a lengthy MS DOS batch file as I found no definitive answer to my issue when searching the Internet and others had not so dissimilar questions regarding mounting USB devices. My hope is that others may gain knowledge by way of my example. The additional 2 files mentioned are as follows;

              Autorun.inf file contents
              [autorun]
              open=MountRUN.bat

              MountRUN.bat file contents
              @echo off
              break on
              c:
              call c:\software\MountVol\MountUSB.bat
              exit

              Biker Steve



                Rookie

                Re: How to Control USB POrt (on/off) using batch file?
                « Reply #9 on: February 13, 2009, 06:08:13 AM »
                In answer to the question "Why do you have all those @echo or @echo. then cls. You just type @echo off and you don't need to have all those @'ts. Then you Just do @echo on to turn it back on again.".

                They are placed within the MS DOS batch file to aid in both the reading and the understanding of how the MS DOS commands execute within any given MSDOS command window.


                Dias de verano

                • Guest
                Re: How to Control USB POrt (on/off) using batch file?
                « Reply #10 on: February 13, 2009, 02:48:39 PM »
                Biker Steve, he wants to know why you use all those @ signs in your code.

                So do I.
                « Last Edit: February 18, 2009, 10:51:02 AM by Dias de verano »

                Biker Steve



                  Rookie

                  Re: How to Control USB POrt (on/off) using batch file?
                  « Reply #11 on: February 18, 2009, 05:28:39 AM »
                  In answer to “Dias de verano” following statement and question “Biker Steve, he wants to know whay you use all those @ signs in your code. So do I.”.

                  I already know why I used all those signs within my code as I am “Biker Steve” and for the benefit of answering “Dias de verano” question
                  here is my answer once again; “They are placed within the MS DOS batch file to aid in both the reading and the understanding of how the MS DOS commands execute within any given MSDOS command window.”.

                  Dias de verano

                  • Guest
                  Re: How to Control USB POrt (on/off) using batch file?
                  « Reply #12 on: February 18, 2009, 10:13:32 AM »
                  It seems, Biker Steve, that you have failed to understand the question. Also, your use of all those @ signs proves that you do not understand batch code properly. And your answer begins to suggest that you are a troll.

                  Batchfilecommand, I expect he cannot answer the question because he copied the code and has no idea why the @ signs are there.



                  « Last Edit: February 18, 2009, 10:35:28 AM by Dias de verano »

                  Biker Steve



                    Rookie

                    Re: How to Control USB POrt (on/off) using batch file?
                    « Reply #13 on: February 18, 2009, 02:18:20 PM »

                    You may wish to know that I have written thousands of MS-DOS batch files over many years.

                    The batch file uses some fundamental MS-DOS batch file commands.

                    The "@echo." command displays a blank line within an MS-DOS command Window.

                    The "@echo off" command turns off the display of MS-DOS commands within the MS-DOS command Window.

                    The "@echo on" command turns on the display of  MS-DOS commands within the MS-DOS command Window.

                    I do hope that I have  now answered your question.

                    Dias de verano

                    • Guest
                    Re: How to Control USB POrt (on/off) using batch file?
                    « Reply #14 on: February 18, 2009, 02:45:39 PM »

                    You may wish to know that I have written thousands of MS-DOS batch files over many years.

                    The batch file uses some fundamental MS-DOS batch file commands.

                    The "@echo." command displays a blank line within an MS-DOS command Window.

                    The "@echo off" command turns off the display of MS-DOS commands within the MS-DOS command Window.

                    The "@echo on" command turns on the display of  MS-DOS commands within the MS-DOS command Window.

                    I do hope that I have  now answered your question.


                    We know about @echo off. We know what @echo does. We want to know why you have a zillion lines starting @echo when you could just put @echo off at the start. And use echo. instead of @echo.


                    Code: [Select]
                    rem This command displays the available "shares"
                    @echo on
                    net share
                    @echo off

                    And why you do this