Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


script that copy file from c:\test\test.txt to (%systemroot%,%programfiles%

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,33843
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> script that copy file from c:\test\test.txt to (%systemroot%,%programfiles%
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 script that copy file from c:\test\test.txt to (%system... - 4/25/2006 12:00:29 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
Hi ,
 
I’m looking for script that copy file or folder from c:\test\test.txt to one of those variables (%systemroot%,%programfiles%,%SystemDrive%, etc…) how I do it?
 
 
Post #: 1
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 1:14:09 AM   
  ginolard


Posts: 1068
Score: 21
Joined: 8/10/2005
Status: offline
Search the forums for CopyFile method and Shell.Environment

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to avipenina)
 
 
Post #: 2
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 1:46:37 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
This will echo the different paths you were looking for.
Last part of code will copy file to the Windows Directory.


      

(in reply to avipenina)
 
 
Post #: 3
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 1:47:56 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
quote:

ORIGINAL: ginolard

Search the forums for CopyFile method and Shell.Environment


i searched but didn't find any answer to my question, is there anyone that can answer my question???

(in reply to ginolard)
 
 
Post #: 4
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 1:56:05 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
quote:

ORIGINAL: Country73

This will echo the different paths you were looking for.
Last part of code will copy file to the Windows Directory.


      


thanks , but where is the source file path and where is the destination path that i want the file will be, example ""%SystemDrive%\test" this is where i want the file to be placed + i get this error message   Microsoft VBScript runtime error: Permission denied

< Message edited by avipenina -- 4/25/2006 1:58:53 AM >

(in reply to Country73)
 
 
Post #: 5
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 2:04:02 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
We don't generally write complete scripts for people. Coutry73 has given you the pieces to do what you want. It is up to you to put them into a script that meets your requirements.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to avipenina)
 
 
Post #: 6
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 2:10:49 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Being generous again...


quote:


I’m looking for script that copy file or folder from c:\test\test.txt to one of those variables (%systemroot%,%programfiles%,%SystemDrive%, etc…) how I do it?


I did forget to put in the & "\" on my initial post, but if you were to run this script it will display what you are looking for.
Un-comment the rest to actually copy the file to the designated location:


      

(in reply to avipenina)
 
 
Post #: 7
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 6:52:17 AM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
quote:

ORIGINAL: Country73

Being generous again...


quote:


I'm looking for script that copy file or folder from c:\test\test.txt to one of those variables (%systemroot%,%programfiles%,%SystemDrive%, etc…) how I do it?


I did forget to put in the & "\" on my initial post, but if you were to run this script it will display what you are looking for.
Un-comment the rest to actually copy the file to the designated location:


      



Ok,thanks it'a working great , now can you tell me how to put on this script that i will copy more files to the same location
if i have this code

strMyFile = "C:\test\test.txt"

'Copy file into SystemRoot
'If oFS.FileExists(strMyFile)Then
'   oFS.CopyFile strMyFile, strWinDir & "\"
'End If
and i want to copy another file to the same location i can't do that

strMyFile = "C:\test\test.txt"
strMyFile = "C:\test2\test2.txt"

'Copy file into SystemRoot
if oFS.FileExists(strMyFile)Then
  oFS.CopyFile strMyFile, strWinDir & "\"
End If

the script doesn't copy those files it's copy only one why?

(in reply to Country73)
 
 
Post #: 8
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 7:08:02 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
you can use wildcards in the source string. So if those are the only 2 .txt files in that folder, this would work:

strMyFile = "C:\Test\*.txt"
oFS.CopyFile strMyFile, strWinDir & "\"

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to avipenina)
 
 
Post #: 9
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 6:03:47 PM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
quote:

ORIGINAL: ebgreen

you can use wildcards in the source string. So if those are the only 2 .txt files in that folder, this would work:

strMyFile = "C:\Test\*.txt"
oFS.CopyFile strMyFile, strWinDir & "\"


no this is not what i meant, i meant that i want to copy more files to the same location like the script that we have below, why both strMyFile aren't copy to the location,but only one of them is copied,what's wrong with this code?

Set oFS = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

strWinDir = oShell.ExpandEnvironmentStrings("%WinDir%")
strProgFiles = oShell.SpecialFolders("Programs")
strSysDrive = oShell.ExpandEnvironmentStrings("%SystemDrive%")

wscript.echo strWinDir & vbcr & strProgFiles & vbcr & strSysDrive

'This is the file you wish to copy

strMyFile = "C:\test\test.txt"
strMyFile = "d:\test\*.*"
'Copy file into SystemRoot
If oFS.FileExists(strMyFile)Then
oFS.CopyFile strMyFile, strWinDir & "\"
End If

(in reply to ebgreen)
 
 
Post #: 10
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 7:34:41 PM   
  ehvbs

 

Posts: 2204
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi avipenina,

strMyFile = "C:\test\test.txt"
strMyFile = "d:\test\*.*"                                       <--  strMyFile contains a wildcard
'Copy file into SystemRoot
If oFS.FileExists(strMyFile)Then                            <--  oFS.FileExists will return False (because of the wildcard)
    oFS.CopyFile strMyFile, strWinDir & "\"             <--  Never reached
End If

(in reply to avipenina)
 
 
Post #: 11
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/25/2006 8:05:27 PM   
  avipenina

 

Posts: 102
Score: 0
Joined: 4/24/2006
Status: offline
so what is the right code to make this script to copy few files from different locations to the same directory?

(in reply to ehvbs)
 
 
Post #: 12
 
 RE: script that copy file from c:\test\test.txt to (%sy... - 4/26/2006 1:15:27 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: offline
You would have to create a list of the files to copy (I would use an array if the list is not too long). Then loop through the array calling the copy for each file.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to avipenina)
 
 
Post #: 13
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> script that copy file from c:\test\test.txt to (%systemroot%,%programfiles% Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts