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

Author Topic: help with some things in dos  (Read 9948 times)

0 Members and 1 Guest are viewing this topic.

get2500

    Topic Starter


    Greenhorn

    help with some things in dos
    « on: September 14, 2009, 05:24:40 PM »
    im trying to make a batch file search for and execute a java HTML file for the applet viewer. all im missing is the command to search and execute a file when found. if someone could help me it would be appreciated.

    thxx

    billrich

    • Guest
    Re: help with some things in dos
    « Reply #1 on: September 14, 2009, 06:21:23 PM »
    ?
    « Last Edit: September 17, 2009, 12:49:33 PM by billrich »

    get2500

      Topic Starter


      Greenhorn

      Re: help with some things in dos
      « Reply #2 on: September 14, 2009, 06:22:54 PM »
      yes but how do you copy the directory that it gives you so that you can change directories so you can tell it to run the file

      billrich

      • Guest
      Re: help with some things in dos
      « Reply #3 on: September 14, 2009, 06:45:37 PM »
      Is the  java HTML  on your machine or some where on the internet?

      http://www.cs.colostate.edu/helpdocs/JavaInDOS.html


      get2500

        Topic Starter


        Greenhorn

        Re: help with some things in dos
        « Reply #4 on: September 14, 2009, 07:07:32 PM »
        on the machine but i need it to search the computer for the file then change the directory to where its located

        billrich

        • Guest
        Re: help with some things in dos
        « Reply #5 on: September 14, 2009, 07:49:55 PM »

        C:\>cd \

        use *.htm  if you do not know the name of the file

        C:\>dir /s timezone.htm
         Volume in drive C has no label.
         Volume Serial Number is F4A3-D6B3

         Directory of C:\WINDOWS\system32\oobe\setup

        04/14/2008  07:00 AM             3,099 timezone.htm
                       1 File(s)          3,099 bytes

             Total Files Listed:
                       1 File(s)          3,099 bytes
                       0 Dir(s)  307,248,930,816 bytes free

        C:\>cd  C:\WINDOWS\system32\oobe\setup

        C:\WINDOWS\system32\oobe\setup>dir timezone.htm
         Volume in drive C has no label.
         Volume Serial Number is F4A3-D6B3

         Directory of C:\WINDOWS\system32\oobe\setup

        04/14/2008  07:00 AM             3,099 timezone.htm
                       1 File(s)          3,099 bytes
                       0 Dir(s)  307,249,434,624 bytes free

        C:\WINDOWS\system32\oobe\setup>

        get2500

          Topic Starter


          Greenhorn

          Re: help with some things in dos
          « Reply #6 on: September 16, 2009, 09:07:25 PM »
          ya but im running a batch file so how do i get it to put that directory that it found into a directory change on its own

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #7 on: September 17, 2009, 04:02:35 AM »
          yes, but I'm running a batch file so how do I get it to put that directory that it found into a directory change on its own.

          Each program ( or command ) that is typed at the command prompt may be placed in a batch file and each line will execute as if you typed at the program at  the  command prompt.

          Any program will execute if you show the complete path to the program. You need  not CD to the folder containing the program. Either method can be used. It does not hurt to CD to the folder (directory ) containing the program.

          Once the location of the program is known, the search for the program is not required each time.

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: help with some things in dos
          « Reply #8 on: September 17, 2009, 04:29:33 AM »
          Well you could do dir /b /s within a for loop.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #9 on: September 17, 2009, 09:44:29 AM »
          Well you could do dir /b /s within a for loop.

          The above would find the program and the location of the program ( assuming  the OP knows the name of the program. )  When the program is found, is the program executed or do we CD to the directory where the program is located?  Will the program be in a different directory each time the batch file is run?

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #10 on: September 17, 2009, 02:10:07 PM »
          Code: [Select]
          @echo off

          dir /s /b  msinfo32.exe


          dir /s /b msinfo32.exe  >  ms.txt

          echo ms.txt
          echo.
          type  ms.txt



          set /p var=< ms.txt

          echo  var = %var%

          "%var%"
          "C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe"
          C:\>

          Output:

          C:\>msin.bat
          C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe
          C:\WINDOWS\system32\dllcache\msinfo32.exe
          ms.txt

          C:\Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe
          C:\WINDOWS\system32\dllcache\msinfo32.exe
           var = C:\Program Files\Common Files\MicrosoftShared\MSInfo\msinfo32.exe

          C:\>
          « Last Edit: September 17, 2009, 02:52:34 PM by billrich »

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: help with some things in dos
          « Reply #11 on: September 17, 2009, 03:17:09 PM »
          What if there is more than one of the file? It will only run the first one found.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #12 on: September 17, 2009, 03:23:06 PM »
          Code: [Select]
          REM This batch will find a folder ( directory ) and
          REM cd to that directory
          REM USAGE:  MSDIR  MSInfo

          @echo off



          dir /s /b  %1

          dir /s /b %1  >  ms.txt

          echo ms.txt
          echo.
          type  ms.txt



          set /p var=< ms.txt

          echo  var = %var%

          echo.
          echo cd to %1 using variable

          cd  "%var%"

          Output:

          C:\>MSDir.bat  MSinfo

          C:\>REM This batch will find a folder ( directory ) and

          C:\>REM cd to that directory

          C:\>REM USAGE:  MSDIR  MSInfo
          C:\Program Files\Common Files\Microsoft Shared\MSInfo
          C:\WINDOWS\msapps\msinfo
          ms.txt

          C:\Program Files\Common Files\Microsoft Shared\MSInfo
          C:\WINDOWS\msapps\msinfo
           var = C:\Program Files\Common Files\Microsoft Shared\MSInfo

          cd to MSinfo using variable
          C:\Program Files\Common Files\Microsoft Shared\MSInfo>
          « Last Edit: September 18, 2009, 01:48:11 PM by billrich »

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #13 on: September 17, 2009, 03:32:02 PM »
          Well you could do dir /b /s within a for loop.

          Store the files and the path to the files in a text file and use a for loop.

          The text file will quickly become very large when a search is done for all *.htm files or all *.bat files.  When each file is a .htm or .exe,  time and information would be nearly unmanageable.

          The original Poster needs to know the name of the file he is looking for.


          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: help with some things in dos
          « Reply #14 on: September 17, 2009, 03:35:44 PM »
          Store the files and the path to the files in a text file and use a for loop.

          The text file will quickly become very large when a search is done for all *.htm files or all *.bat files.  When each file is a .htm or .exe,  time and information would be nearly unmanageable.

          The original Poster needs to know the name of the file he is looking for.


          Don't bother putting it in a text file, do the dir directly in the for loop.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #15 on: September 17, 2009, 03:58:34 PM »
          Don't bother putting it in a text file, do the dir directly in the for loop.

          Show us the code.  Search for all  *.htm files on you computer and execute each file.

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: help with some things in dos
          « Reply #16 on: September 17, 2009, 04:06:14 PM »
          For /f "delims=" %%a in ('dir /b /s *.htm') do echo %%a
          Pause > nul

          That will display all htm files, you can replace echo with whatever you want.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #17 on: September 17, 2009, 04:22:39 PM »
          For /f "delims=" %%a in ('dir /b /s *.htm') do echo %%a
          Pause > nul

          That will display all htm files, you can replace echo with whatever you want.

          Get2500, the original poster,  does not want to use the complete path to the file.  Get2500 needs to find the directory each file is in, cd to that directory and then execute the file.

          By the way, does your for loop run from the root directory or some other directory?

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: help with some things in dos
          « Reply #18 on: September 17, 2009, 04:30:38 PM »
          Ok. Well as long as the path name doesn't have a . setting the delims to . will work.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          billrich

          • Guest
          Re: help with some things in dos
          « Reply #19 on: September 17, 2009, 04:51:37 PM »
          Ok. Well as long as the path name doesn't have a . setting the delims to . will work.


          What?

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: help with some things in dos
          « Reply #20 on: September 17, 2009, 05:06:36 PM »
          Ohh nevermind, I was thinking of getting filename without extension.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          get2500

            Topic Starter


            Greenhorn

            Re: help with some things in dos
            « Reply #21 on: September 19, 2009, 11:34:42 AM »
            i need it to cd to the directory like billrich said

            billrich

            • Guest
            Re: help with some things in dos
            « Reply #22 on: September 19, 2009, 11:40:16 AM »
            i need it to cd to the directory

            Why?  A complete path to the file works better.

            Code: [Select]
            REM This batch will find a folder ( directory ) and
            REM cd to that directory
            REM USAGE:  MSDIR  MSInfo

            @echo off



            dir /s /b  %1

            dir /s /b %1  >  ms.txt

            echo ms.txt
            echo.
            type  ms.txt



            set /p var=< ms.txt

            echo  var = %var%

            echo.
            echo cd to %1 using variable

            cd  "%var%"
            Output:

            C:\>MSDir.bat  MSinfo

            C:\>REM This batch will find a folder ( directory ) and

            C:\>REM cd to that directory

            C:\>REM USAGE:  MSDIR  MSInfo
            C:\Program Files\Common Files\Microsoft Shared\MSInfo
            C:\WINDOWS\msapps\msinfo
            ms.txt

            C:\Program Files\Common Files\Microsoft Shared\MSInfo
            C:\WINDOWS\msapps\msinfo
             var = C:\Program Files\Common Files\Microsoft Shared\MSInfo

            cd to MSinfo using variable
            C:\Program Files\Common Files\Microsoft Shared\MSInfo>

            get2500

              Topic Starter


              Greenhorn

              Re: help with some things in dos
              « Reply #23 on: September 19, 2009, 11:42:48 AM »
              well when i cd to the complete path it says "invalid path"

              get2500

                Topic Starter


                Greenhorn

                Re: help with some things in dos
                « Reply #24 on: September 19, 2009, 11:46:29 AM »
                nvm i finally solved it

                someone posted
                Code: [Select]
                For /f "delims=" %%a in ('dir /b /s *.html') do echo %%a
                Pause > nul
                and i changed "do echo" to "do appletviewer %%a"

                billrich

                • Guest
                Re: help with some things in dos
                « Reply #25 on: September 19, 2009, 11:47:00 AM »
                well when I cd to the complete path it says "invalid path"

                Don't CD. Your file is not a directory.

                copy and paste the complete path to the command prompt and press enter

                or place the complete path in batch file and run

                Post your Batch file.

                get2500

                  Topic Starter


                  Greenhorn

                  Re: help with some things in dos
                  « Reply #26 on: September 19, 2009, 12:08:15 PM »
                  Code: [Select]
                  @echo off
                  echo.
                  echo RULES
                  echo.
                  echo Use your mouse to move the paddle and hit the ball
                  PING 1.1.1.1 -n 1 -w 2000 >NUL
                  echo Ball changes color when spin is applied
                  PING 1.1.1.1 -n 1 -w 2000 >NUL
                  echo The faster the ball is going the more points you get
                  PING 1.1.1.1 -n 1 -w 2000 >NUL
                  echo If you miss the ball you lose 1000 points
                  PING 1.1.1.1 -n 1 -w 2000 >NUL
                  echo.

                  echo READY
                  PING 1.1.1.1 -n 1 -w 3000 >NUL
                  echo.

                  echo SET
                  echo.
                  PING 1.1.1.1 -n 1 -w 3000 >NUL

                  echo GO!
                  For /f "delims=" %%a in ('dir /b /s *.html') do appletviewer %%a
                  Pause > nul


                  i already solved it tho

                  billrich

                  • Guest
                  Re: help with some things in dos
                  « Reply #27 on: September 19, 2009, 12:42:01 PM »
                  Get2500,

                  I'm happy you solved the problem.

                  How many .html  files were there?

                  In what directory were the .html files?


                  You solved the problem but I'm still confused.

                  Thanks for your help
                  « Last Edit: September 19, 2009, 01:54:40 PM by billrich »

                  get2500

                    Topic Starter


                    Greenhorn

                    Re: help with some things in dos
                    « Reply #28 on: September 19, 2009, 08:19:59 PM »
                    well, the code that worked for me...didnt work all the time. how do u get that part of code
                    Code: [Select]
                    For /f "delims=" %%a in ('dir /b /s *.html') do echo %%a
                    Pause > nul
                    to work for all drives. like if i have the files on a flash drive

                    Helpmeh



                      Guru

                    • Roar.
                    • Thanked: 123
                      • Yes
                      • Yes
                    • Computer: Specs
                    • Experience: Familiar
                    • OS: Windows 8
                    Re: help with some things in dos
                    « Reply #29 on: September 19, 2009, 08:36:32 PM »
                    Before the *, add this E:\ (or whatever drive), so it looks like E:\*.htm
                    Where's MagicSpeed?
                    Quote from: 'matt'
                    He's playing a game called IRL. Great graphics, *censored* gameplay.

                    billrich

                    • Guest
                    Re: help with some things in dos
                    « Reply #30 on: September 19, 2009, 08:38:35 PM »

                    C:\>type  htmldrive.bat
                    Code: [Select]
                    REM  htmldrive.bat  E
                    @echo off

                    %1:
                    For /f "delims=" %%a in ('dir /b /s *.htm') do echo %%a

                    Output:

                    C:\>
                    C:\>htmldrive.bat E

                    C:\>REM  htmldrive.bat  E
                    E:\bookmark.htm
                    E:\eTrust EZ AntivirusS.htm
                    E:\maukiegrey.htm
                    E:\signature.html
                    E:\so.htm
                    E:\South.htm
                    E:\upgrade.htm
                    E:\walkthetalk_swf.htm
                    E:\CH.pps\aP Lite Flash\index.html
                    E:\CH.pps\PowerPoint\index.html

                    E:\>
                    « Last Edit: September 19, 2009, 09:01:41 PM by billrich »