Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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


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





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