How to copy a hidden file

  • Thread starter Thread starter Wensi Peng
  • Start date Start date
W

Wensi Peng

Hello,

How to have a VBscript or batch file to copy a hidden file from a server to
a remote server?

Thanks,
Wensi
 
1. Use FSO to unhide the file, copy it, re-hide it.
2. Shell out to XCOPY with the /h switch to copy hidden files.

--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//
Hello,

How to have a VBscript or batch file to copy a hidden file from a server to
a remote server?

Thanks,
Wensi
 
In said:
Hello,

How to have a VBscript or batch file to copy a hidden file from a
server to a remote server?

XCOPY /?
...
/H Copies hidden and system files also.
...
 
I tried it and how to suppress the question F or D ? I know boot.ini is a
file.

I want xcopy run in a batch file.

I want the destination file removed hidden after copying. How?

Also how about using robocopy to do the same job?

Example:

E:\Documents and Settings\Max>xcopy /h /i c:\boot.ini c:\boot2.ini
Does C:\boot2.ini specify a file name
or directory name on the target
(F = file, D = directory)?



Thanks,

Wensi
 
I tried it and how to suppress the question F or D ? I know
boot.ini is a file.

I want xcopy run in a batch file.

I want the destination file removed hidden after copying. How?

Also how about using robocopy to do the same job?

Example:

E:\Documents and Settings\Max>xcopy /h /i c:\boot.ini c:\boot2.ini
Does C:\boot2.ini specify a file name
or directory name on the target
(F = file, D = directory)?

You did not say your OS.

One way may be
echo/F|xcopy /h c:\boot.ini c:\boot2.ini
Attrib -s -h -r c:\boot2.ini

Or
attrib -s -h -r c:\boot.ini
copy c:\boot.ini c:\boot2.ini
attrib +s +h +r c:\boot.ini

I can't give you the robocopy syntax.
For other purposes XXcopy may be of interest.
 
Wensi said:
Hello,

How to have a VBscript or batch file to copy a hidden file from a server to
a remote server?
Copied and tweaked from portable script center:
"Copying a File",
"Enumerating File Attributes" and
"Modifying File Atttributes""

'---------------------------------------------------
Dim Src, Dest, SrcAtt
Src="\\Server1\c$\boot.ini"
Dest="\\Server2\c$\boot2.ini"

Set objFSO = CreateObject("Scripting.FileSystemObject")

'copy file
Const OverwriteExisting = True
objFSO.CopyFile Src ,Dest , OverwriteExisting

' get source attributes
Set objFile = objFSO.GetFile(Src)
SrcAtt = objFile.Attributes

' set dest attributes
Set objFile = objFSO.GetFile(Dest)
objFile.Attributes = SrcAtt

set objFile = Nothing
'---------------------------------------------------

HTH
 
My fist question was:

when I run the command "xcopy /h /i c:\boot.ini c:\boot2.ini" I am prompted
if boot2.ini is a File or Directory.
It requires interactive work. How can I suppress the question?

Thanks,
Wensi
 
Thanks for your post.
I prefer to use xcopy. The problem is I am prompted to ask if a destination
is a file or directory.
I wan to suppress the interactive question in a batch file.

Thanks,
Wensi
 
In said:
My fist question was:

when I run the command "xcopy /h /i c:\boot.ini c:\boot2.ini" I am
prompted if boot2.ini is a File or Directory.
It requires interactive work. How can I suppress the question?

Which was my first answer... :-)
 
You should state that in your question then.
Why dd you crosspost to a vbscript group when you aren't interrestes in a
vbs solution?
Thanks for your post.
I prefer to use xcopy. The problem is I am prompted to ask if a destination
is a file or directory.
I wan to suppress the interactive question in a batch file.
Looks like you didn't even try one of Marks work arounds.
 
in message
: In microsoft.public.win2000.cmdprompt.admin Wensi Peng wrote:
:
: One way may be
: echo/F|xcopy /h c:\boot.ini c:\boot2.ini
: Attrib -s -h -r c:\boot2.ini

He wants it hidden after copying so only the first line is needed and
boot.ini is not read-only, just system and hidden.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
In said:
in message
: In microsoft.public.win2000.cmdprompt.admin Wensi Peng wrote:
:
: One way may be
: echo/F|xcopy /h c:\boot.ini c:\boot2.ini
: Attrib -s -h -r c:\boot2.ini
He wants it hidden after copying so only the first line is needed
and boot.ini is not read-only, just system and hidden.


"I want the destination file removed hidden after copying. How?"

Too many variables and possibilities, but I read that as "visible
using ordinary means." FWIW.

If it is +S and viewed through the GUI with default settings, it will
still be "hidden".
Source *might* be +R, or any combination really since the initial
state was not mentioned and cannot really be assumed. But since
"/k" was not used, "-r" is likely superfluous.

Maybe -s -h -r -a is more thorough though since no request was made
about determining the state of those 4 attributes after the copy. <G>
 
One solution would be:
xcopy C:\boot.ini \\Machine2\c$\boot2.ini /H < F.txt

Where F.txt contains a singe "F" character.

--
MikeVa [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--
Please do not send e-mail directly to this alias.
This alias is for newsgroup purposes only.
--
Wensi Peng said:
Thanks for your post.
I prefer to use xcopy. The problem is I am prompted to ask if a
destination
is a file or directory.
I wan to suppress the interactive question in a batch file.

Thanks,
Wensi
 
Back
Top