Computer Hope

Microsoft => Microsoft DOS => Topic started by: nwlun on June 07, 2007, 04:07:40 AM

Title: *confirm* Hidden batch help??
Post by: nwlun 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:\
Title: Re: Hidden batch help??
Post by: Sidewinder 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)
Title: Re: Hidden batch help??
Post by: nwlun 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
Title: Re: Hidden batch help??
Post by: contrex 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:\>
Title: Re: Hidden batch help??
Post by: Carbon Dudeoxide 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.
Title: Re: Hidden batch help??
Post by: contrex 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:\>

Title: Re: Hidden batch help??
Post by: Carbon Dudeoxide on June 07, 2007, 08:07:53 AM
Lol. Well what I did doesn't work for my program....
Title: Re: Hidden batch help??
Post by: contrex 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?


Title: Re: Hidden batch help??
Post by: ghostdog74 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
Title: Re: Hidden batch help??
Post by: nwlun 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
Title: Re: Hidden batch help??
Post by: WillyW 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.

Title: Re: Hidden batch help??
Post by: ghostdog74 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?)
Title: Re: Hidden batch help??
Post by: WillyW 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.


Title: Re: Hidden batch help??
Post by: contrex 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.
Title: Re: Hidden batch help??
Post by: GuruGary 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")
Title: Re: Hidden batch help??
Post by: nwlun 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
Title: Re: Hidden batch help??
Post by: GuruGary on June 08, 2007, 04:36:21 PM
But that same code does work when the file is not hidden?
Title: Re: Hidden batch help??
Post by: nwlun 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
Title: Re: Hidden batch help??
Post by: GuruGary 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

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.
Title: Re: Hidden batch help??
Post by: nwlun 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
 
Title: Re: Hidden batch help??
Post by: contrex 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?

Title: Re: Hidden batch help??
Post by: nwlun on June 09, 2007, 01:01:17 AM

[/quote]

Huh??? That means what?


[/quote]

u test it then u know
Title: Re: Hidden batch help??
Post by: GuruGary 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")
Title: Re: Hidden batch help??
Post by: contrex 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?



Title: Re: Hidden batch help??
Post by: nwlun 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
Title: Re: Hidden batch help??
Post by: Fen_Li 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
Title: Re: Hidden batch help??
Post by: nwlun 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
Title: Re: *confirm* Hidden batch help??
Post by: Fen_Li 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...
 :(
Title: Re: *confirm* Hidden batch help??
Post by: contrex on June 11, 2007, 10:14:05 AM
I also am wondering what he means by "hidden mode"...

Title: Re: *confirm* Hidden batch help??
Post by: 2k_dummy 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
Title: Re: *confirm* Hidden batch help??
Post by: Dark Blade 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.
Title: Re: *confirm* Hidden batch help??
Post by: nwlun 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
Title: Re: *confirm* Hidden batch help??
Post by: Dark Blade 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.

Title: Re: *confirm* Hidden batch help??
Post by: nwlun 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
Title: Re: *confirm* Hidden batch help??
Post by: contrex on June 13, 2007, 11:24:56 AM
Confirmation of what? That a hidden batch file cannot copy itself?

It is confirmed.