Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > VBScript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 5th, 2007, 02:45 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy command not working

Hi,

I wrote a script to copy a file from one drive to another

Dim oShell, oExec, sSyntax, nreturn
Set oShell = CreateObject("Wscript.Shell")
sSyntax = "copy c:file1 d:file2"
nreturn = oShell.Run(sSyntax)
Wscript.Echo nreturn

I get a error "System cannot find the file specified"

but if I give the same command from command prompt it works fine.
any one has the same issue. If any one has resolved it or has any suggessions please let me know.

Reply With Quote
  #2 (permalink)  
Old July 5th, 2007, 05:24 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks anyways I have found the answer. It may be helpfull for you in case..

copy is an internal command, so you cannot run in this way (a file called
copy.exe doesn't exist on your hard drive, so "System cannot find the file
specified"). You need to do:
sSyntax = "%comspec% /c copy c:file1 d:file2"
this uses the command prompt to execute the copy command



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
Trouble creating a Copy Record command on a Form Ron V Access 0 May 19th, 2004 01:36 PM
Get Working Copy... not working Enkiel Classic ASP Basics 0 April 21st, 2004 01:41 PM
Command button not working in ms access page mohiddin52 Access 1 December 14th, 2003 06:52 PM



All times are GMT -4. The time now is 04:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.