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 25315 times)

0 Members and 1 Guest are viewing this topic.

Biker Steve



    Rookie

    Re: How to Control USB POrt (on/off) using batch file?
    « Reply #15 on: February 18, 2009, 03:17:32 PM »

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

    The "rem" command is used in this instance to document the following procedure.

    The "Net Share" command displays the current status of any active "share(s)".

    The "@echo on" switches on the display of the "Net Share" command and when the command is completed the "@echo off" command switches the display of any further following command to "off" until such time as may be another "@echo on" command is executed.

    I do hope that I have answered your question once again.

    At this rate before I know it I will be a "Guru" on this site by just answering all your questions.


    Dias de verano

    • Guest
    Re: How to Control USB POrt (on/off) using batch file?
    « Reply #16 on: February 18, 2009, 03:46:40 PM »
    But echo off / on merely suppresses the echoing of internal commands. You really don't understand batch, do you? All that your @echo on does is force a prompt to be displayed. And you still haven't answered the question. Because you can't, maybe?

    v1.bat

    Code: [Select]
    @echo off
    @echo Now running net share
    @echo.
    @echo on
    net share
    @echo off

    v2.bat
    Code: [Select]
    @echo off
    echo Now running net share
    echo.
    net share

    The results...

    Code: [Select]
    S:\>v1.bat
    Now running net share


    S:\>net share

    Share name   Resource                        Remark

    -------------------------------------------------------------------------------
    IPC$                                         Remote IPC
    The command completed successfully.

    Code: [Select]
    S:\>v2.bat
    Now running net share


    Share name   Resource                        Remark

    -------------------------------------------------------------------------------
    IPC$                                         Remote IPC
    The command completed successfully.


    Biker Steve



      Rookie

      Re: How to Control USB POrt (on/off) using batch file?
      « Reply #17 on: February 18, 2009, 04:03:21 PM »

       :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(

      @echo off
      break on
      @echo.
      @echo.
      @echo.
      @echo This has just become a futile discussion with your added sarcasms.
      @echo.
      @echo Therefore I am being mature about this and ending it here and now!
      @echo.
      @echo.
      pause
      exit

       :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(

      GuruGary



        Adviser
        Re: How to Control USB POrt (on/off) using batch file?
        « Reply #18 on: February 18, 2009, 08:27:29 PM »
        Poor Steve.  He was just trying to help. 

        His code was long with a lot of extra statements and not very efficient, but I didn't see any obvious logic or syntax errors.  Looking at his code, I just assumed he worked for the government.

        BatchRocks



          Hopeful
        • Thanked: 3
          Re: How to Control USB POrt (on/off) using batch file?
          « Reply #19 on: February 19, 2009, 09:58:17 AM »
          @echo off
          echo Dias is right.
          echo.
          pause>nul
          exit.

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: How to Control USB POrt (on/off) using batch file?
          « Reply #20 on: February 19, 2009, 04:13:51 PM »

           :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(

          @echo off
          break on


          @echo.
          @echo.
          @echo.
          @echo This has just become a futile discussion with your added sarcasms.
          @echo.
          @echo Therefore I am being mature about this and ending it here and now!
          @echo.
          @echo.
          pause
          exit

           :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'( :'(

          why the "BREAK"?

          according to the output from "help break"

          Quote
          This is present for Compatibility with DOS systems. It has no effect
          under Windows XP
          .

          If Command Extensions are enabled, and running on the Windows XP
          platform, then the BREAK command will enter a hard coded breakpoint
          if being debugged by a debugger.

          And even with a DOS targeted batch the "Break" command at least as far as I know is only a Config.sys command.

          LOL I just had to keep the prodding up  ;)
          I was trying to dereference Null Pointers before it was cool.

          Biker Steve



            Rookie

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

            When under taking the MS DOS "Help Break" command you have failed to mention that the command also displays the line "Sets or Clears Extended Ctrl+C checking on DOS systems".

            In simple terms what this means is that when executing this fundamental "Break On" command from within a MS-DOS batch file a user can terminate the operation of the MS-DOS file prematurely by pressing both the "Ctrl and C" keyboard keys together. You will then be asked "Terminate batch job (Y/N)".



            macdad-



              Expert

              Thanked: 40
              Re: How to Control USB POrt (on/off) using batch file?
              « Reply #22 on: February 20, 2009, 06:49:15 PM »
              lets just say to the OP, get MS's Devcon.....

              end of story....bye bye...see you later
              If you dont know DOS, you dont know Windows...

              Thats why Bill Gates created the Windows NT Family.

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: How to Control USB POrt (on/off) using batch file?
              « Reply #23 on: February 20, 2009, 08:46:06 PM »

              When under taking the MS DOS "Help Break" command you have failed to mention that the command also displays the line "Sets or Clears Extended Ctrl+C checking on DOS systems".

              In simple terms what this means is that when executing this fundamental "Break On" command from within a MS-DOS batch file a user can terminate the operation of the MS-DOS file prematurely by pressing both the "Ctrl and C" keyboard keys together. You will then be asked "Terminate batch job (Y/N)".





              True, but considering there is no MOUNTVOL or a few other commands used in that batch, it's a bit silly to add something that only works on Pure DOS.
              I was trying to dereference Null Pointers before it was cool.