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 19216 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")