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

Author Topic: *confirm* Hidden batch help??  (Read 19154 times)

0 Members and 1 Guest are viewing this topic.

nwlun

  • Guest
*confirm* Hidden batch help??
« on: June 07, 2007, 04:07:40 AM »
this is my batch code

@echo off
echo hello
echo hihi
echo haha
echo lalala
CD\
dir c:\bat.bat /s /b > c:\log.txt
for /f "tokens=*" %%1 in (c:\log.txt) do (copy "%%1" c:\haha.bat
                                          del "%%1")

when i execute it will then self copy itself to c:\
but when i put it as a hidden batch it will not copy itself to c:\
it just said file not found

is there a way i can make it copy to c:\
« Last Edit: June 10, 2007, 11:23:29 PM by nwlun »

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Hidden batch help??
« Reply #1 on: June 07, 2007, 05:19:31 AM »
Try unhiding the file. I've never seen it documented but perhaps some versions of DOS and/or Windows do not allow execution of hidden files.

You can also get the file not found message by misspelling the file name or not having a path to the file.

Good luck. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

nwlun

  • Guest
Re: Hidden batch help??
« Reply #2 on: June 07, 2007, 05:40:32 AM »
well i make it unhidden then it work  ;D
but problem is i test it with hidden then it didnt work

well like you said window do not allow execution of hidden files then no choice

so is there really no choice

contrex

  • Guest
Re: Hidden batch help??
« Reply #3 on: June 07, 2007, 07:36:47 AM »
Well, I can execute hidden files in XP Pro SP2

Quote
C:\>hello.bat
Hello from Contrex

C:\>attrib +H hello.bat

C:\>dir /ah
 Volume in drive C is SystemXP
 Volume Serial Number is 4CCF-8F52

 Directory of C:\

07/06/2007  14:32                36 hello.bat
               1 File(s)             36 bytes
               0 Dir(s)  28,515,368,960 bytes free

C:\>hello.bat
Hello from Contrex

C:\>

Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: Hidden batch help??
« Reply #4 on: June 07, 2007, 07:40:10 AM »
It dosn't work all the time Contrex. I tried hid some program files and I tried running the program but it couldn't locate the files because they had the +h attrib.

contrex

  • Guest
Re: Hidden batch help??
« Reply #5 on: June 07, 2007, 08:06:08 AM »
Quote
C:\>hpar2.exe
par2cmdline version 0.2, Copyright (C) 2003 Peter Brian Clements.

par2cmdline comes with ABSOLUTELY NO WARRANTY.

This is free software, and you are welcome to redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. See COPYING for details.

Not enough command line arguments.

C:\>attrib +H hpar2.exe

C:\>hpar2.exe
par2cmdline version 0.2, Copyright (C) 2003 Peter Brian Clements.

par2cmdline comes with ABSOLUTELY NO WARRANTY.

This is free software, and you are welcome to redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. See COPYING for details.

Not enough command line arguments.

C:\>


Carbon Dudeoxide

  • Global Moderator

  • Mastermind
  • Thanked: 169
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Experience: Guru
  • OS: Mac OS
Re: Hidden batch help??
« Reply #6 on: June 07, 2007, 08:07:53 AM »
Lol. Well what I did doesn't work for my program....

contrex

  • Guest
Re: Hidden batch help??
« Reply #7 on: June 07, 2007, 08:17:57 AM »
I'm confused now! I always thought that hidden files are hidden from DIR etc so you can't copy or rename them but that if you happen to remember their names you can type them in and they work OK. That seems to be the case with a batch file and an exe file that I just tried.

Anyway, lots and lots of viruses rely on executing a hidden file, so it must be possible.

What did you do to test this out?



ghostdog74



    Specialist

    Thanked: 27
    Re: Hidden batch help??
    « Reply #8 on: June 07, 2007, 08:29:24 AM »
    @OP, a plain dir will not show hidden files, unless you give it the /AH switch. But this only show hidden files and not all files. You can do it 2 steps, show all files, then show hidden files.

    however, a vbscript like the below is able to show the hidden files as well
    Code: [Select]
    Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
    sDIR = "c:\temp"
    Set objDIR = FSO.GetFolder(sDIR)
    For Each efile in objDIR.Files
        WScript.Echo efile
        ' script continues here.
    Next

    nwlun

    • Guest
    Re: Hidden batch help??
    « Reply #9 on: June 07, 2007, 09:55:23 AM »
    well vbscript of cause can do alot thing that batch cant do but now what i want to kno that is it possible to copy a file that is hidden to other directory

    WillyW



      Specialist
    • Thanked: 29
    • Experience: Experienced
    • OS: Windows XP
    Re: Hidden batch help??
    « Reply #10 on: June 07, 2007, 10:06:28 AM »
    @OP, a plain dir will not show hidden files, unless you give it the /AH switch. But this only show hidden files and not all files. You can do it 2 steps, show all files, then show hidden files.   ...

    I've used   dir /a     to show all files.

    .



    ghostdog74



      Specialist

      Thanked: 27
      Re: Hidden batch help??
      « Reply #11 on: June 07, 2007, 10:15:31 AM »
      yes, dir /a will display all files, including hidden ones..maybe i read OP requirements wrongly. i thought he wants to unhide a file after processing other visible files. and /a does not really tell you which file is hidden (or does it?)

      WillyW



        Specialist
      • Thanked: 29
      • Experience: Experienced
      • OS: Windows XP
      Re: Hidden batch help??
      « Reply #12 on: June 07, 2007, 10:29:52 AM »
      yes, dir /a will display all files, including hidden ones..maybe i read OP requirements wrongly. i thought he wants to unhide a file after processing other visible files. and /a does not really tell you which file is hidden (or does it?)

      I don't think it does - just displays all.   

      I'm sure I don't fully understand the OP's wants.   :)

      Was merely commenting on, "dir will not show hidden files, unless you give it the /AH switch."  ,   in that it will show hidden files without the  H modifier.
      And that a complete list could be obtained in one step.


      .



      contrex

      • Guest
      Re: Hidden batch help??
      « Reply #13 on: June 07, 2007, 10:33:06 AM »
      The answer to the OP is that hidden files can be run but they can't be copied, so that is why a hidden batch file won't copy itself.

      GuruGary



        Adviser
        Re: Hidden batch help??
        « Reply #14 on: June 07, 2007, 10:25:45 PM »
        You can use XCOPY to copy a hidden file (with the /H switch).
        Code: [Select]
        for /f "tokens=*" %%1 in (c:\log.txt) do (xcopy "%%1" c:\haha.bat /h
           del "%%1")

        nwlun

        • Guest
        Re: Hidden batch help??
        « Reply #15 on: June 08, 2007, 02:27:07 AM »
        You can use XCOPY to copy a hidden file (with the /H switch).
        Code: [Select]
        for /f "tokens=*" %%1 in (c:\log.txt) do (xcopy "%%1" c:\haha.bat /h
           del "%%1")

        tested it and still didnt work
        File not Found

        GuruGary



          Adviser
          Re: Hidden batch help??
          « Reply #16 on: June 08, 2007, 04:36:21 PM »
          But that same code does work when the file is not hidden?

          nwlun

          • Guest
          Re: Hidden batch help??
          « Reply #17 on: June 08, 2007, 06:28:41 PM »
          well it did work in not hidden mode  ::)

          so is it confirm or not confirm that it cannot be copy in hidden mode

          GuruGary



            Adviser
            Re: Hidden batch help??
            « Reply #18 on: June 08, 2007, 09:59:39 PM »
            XCOPY /H is designed to copy hidden files.  So yes, it should work.  Please confirm the following
            • You are using the XCOPY command
            • You are using the /H switch with XCOPY
            • The only thing you are changing is the hidden attribute on the file
            • You are using the exact same code with the test on hidden file and the regular file

            If all the above are true then there is something else going on.  Please confirm and post back with the exact code you are using.

            nwlun

            • Guest
            Re: Hidden batch help??
            « Reply #19 on: June 08, 2007, 11:42:10 PM »
            well yesterday i already manage to make it
            here the code

            @echo off
            echo *censored*
            echo hihi
            echo lol
            echo lalalla
            CD\
            dir c:\bat.bat /s /b > c:\log.txt
            for /f "tokens=*" %%1 in (c:\log.txt) do (xcopy /h "%%1" c:\haha.txt
                                                      del "%%1")

            but i dont want to input the f=file, D=directory key
            i want to make it auto copy
             

            contrex

            • Guest
            Re: Hidden batch help??
            « Reply #20 on: June 09, 2007, 12:40:17 AM »

            but i dont want to input the f=file, D=directory key
            i want to make it auto copy
             

            Huh??? That means what?


            nwlun

            • Guest
            Re: Hidden batch help??
            « Reply #21 on: June 09, 2007, 01:01:17 AM »

            [/quote]

            Huh??? That means what?


            [/quote]

            u test it then u know

            GuruGary



              Adviser
              Re: Hidden batch help??
              « Reply #22 on: June 09, 2007, 01:07:22 AM »
              You are getting the File/Directory prompt because you are copying to a new file name, and neither a file or a directory with that name exist.  You can work around the issue by creating a dummy file to copy over.  Like:
              Code: [Select]
              dir c:\bat.bat /s /b > c:\log.txt
              echo.>c:\haha.txt
              for /f "tokens=*" %%1 in (c:\log.txt) do (xcopy "%%1" c:\haha.txt /h
                 del "%%1")

              contrex

              • Guest
              Re: Hidden batch help??
              « Reply #23 on: June 09, 2007, 01:11:52 AM »
              I just saved that code to my C: drive as tryme.bat, and created a log.txt (an obviously needed step) and ran the batch and got this...

              Quote
              C:\>tryme
              *censored*
              hihi
              lol
              lalalla
              File Not Found

              I didn't get any "file/directory" prompt.

              nwlun, what is the purpose of all this? Why do you want a hidden batch file to copy itself?




              nwlun

              • Guest
              Re: Hidden batch help??
              « Reply #24 on: June 09, 2007, 02:10:33 AM »


              what is the purpose of all this?




              [/quote]

              no it just that few day ago suddenly i make a mistake in my batch where there i put and attrib +h to my batch then i reliaze that it cannot be copy

              it just weird that it cannot be copies that why i ask an expert from here whether it can be copy in hiden mode or not

              Fen_Li



                Beginner

              • G-Smart thing Smart
              • Thanked: 2
                Re: Hidden batch help??
                « Reply #25 on: June 09, 2007, 12:33:36 PM »
                I thing I can help you... ;D

                this is alternate way to copy file and work with hidden & system file..
                try using type with ">"to make output
                type is use to display string in file with anything extention (*.*)..

                ex:
                to copy "c:\whatever.exe" to "c:\folder\whatever.exe", this also work
                type "c:\whatever.exe">"c:\folder\whatever.exe"

                so, your code may like this:
                @echo off
                echo h**l
                echo hihi
                echo lol
                echo lalalla
                CD\
                dir c:\bat.bat /s /b > c:\log.txt
                for /f "tokens=*" %%1 in (c:\log.txt) do (
                      type "%%1">c:\haha.txt
                      del "%%1"
                )

                 :) ;) :D ;D
                ..Still Newbie KID..

                nwlun

                • Guest
                Re: Hidden batch help??
                « Reply #26 on: June 09, 2007, 07:12:46 PM »
                I thing I can help you... ;D

                this is alternate way to copy file and work with hidden & system file..
                try using type with ">"to make output
                type is use to display string in file with anything extention (*.*)..

                ex:
                to copy "c:\whatever.exe" to "c:\folder\whatever.exe", this also work
                type "c:\whatever.exe">"c:\folder\whatever.exe"

                so, your code may like this:
                @echo off
                echo h**l
                echo hihi
                echo lol
                echo lalalla
                CD\
                dir c:\bat.bat /s /b > c:\log.txt
                for /f "tokens=*" %%1 in (c:\log.txt) do (
                      type "%%1">c:\haha.txt
                      del "%%1"
                )

                 :) ;) :D ;D

                well did you try the batch in hidden mode
                well i guess u didnt
                anyway i just need a confirmation only
                thx to all the computer hope member that help me

                Fen_Li



                  Beginner

                • G-Smart thing Smart
                • Thanked: 2
                  Re: *confirm* Hidden batch help??
                  « Reply #27 on: June 11, 2007, 09:59:58 AM »
                  I'm not understand what you assume "Hidden Mode"
                  if you assume "Copy File /w Hidden Attribute" it work fine...
                   :(
                  « Last Edit: June 11, 2007, 10:43:30 AM by Fen_Li »
                  ..Still Newbie KID..

                  contrex

                  • Guest
                  Re: *confirm* Hidden batch help??
                  « Reply #28 on: June 11, 2007, 10:14:05 AM »
                  I also am wondering what he means by "hidden mode"...


                  2k_dummy



                    Specialist
                  • A word, once spoken, can never be recalled.
                  • Thanked: 14
                    Re: *confirm* Hidden batch help??
                    « Reply #29 on: June 11, 2007, 11:01:29 AM »
                    Why not just remove the hidden attribute and copy the file. If bat.bat is to be deleted:
                    @echo off
                    atrib -h c:\bat.bat
                    copy c:\bat.bat c:\haha.bat
                    del c:\bat.bat

                    If haha.bat is to be hidden, add:

                    attrib +h c:\haha.bat
                    If you don't stand for something, you'll fall for anything.
                    _______________________________________ ________
                    BlackViper

                    Software and utilities

                    Dark Blade

                    • Forum Gaming Master


                    • Adviser

                      Thanked: 24
                      • Yes
                    • Experience: Experienced
                    • OS: Windows XP
                    Re: *confirm* Hidden batch help??
                    « Reply #30 on: June 12, 2007, 04:22:02 AM »
                    I think that he might want to keep it hidden/move it while it's hidden. But if it's the former, he could just unhide it, copy it, then hide it.

                    nwlun

                    • Guest
                    Re: *confirm* Hidden batch help??
                    « Reply #31 on: June 12, 2007, 04:50:26 AM »
                    I think that he might want to keep it hidden/move it while it's hidden. But if it's the former, he could just unhide it, copy it, then hide it.

                    that the point

                    Dark Blade

                    • Forum Gaming Master


                    • Adviser

                      Thanked: 24
                      • Yes
                    • Experience: Experienced
                    • OS: Windows XP
                    Re: *confirm* Hidden batch help??
                    « Reply #32 on: June 13, 2007, 12:19:19 AM »
                    What's the point?

                    To keep it hidden/move it while it's hidden
                    Unhide it, copy it, then hide it.


                    nwlun

                    • Guest
                    Re: *confirm* Hidden batch help??
                    « Reply #33 on: June 13, 2007, 01:04:44 AM »
                    What's the point?

                    To keep it hidden/move it while it's hidden
                    Unhide it, copy it, then hide it.



                    im not here to quarell with u .. i just need a confirmation only
                    if like wat u said just now then i wouldnt need a batch at all
                    all i need is to use my hand  to click on it and eye to see it

                    contrex

                    • Guest
                    Re: *confirm* Hidden batch help??
                    « Reply #34 on: June 13, 2007, 11:24:56 AM »
                    Confirmation of what? That a hidden batch file cannot copy itself?

                    It is confirmed.