Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Windows Script with Jscript error trying to move file

Posted on 2004-11-06
Medium Priority
Last Modified: 2011-09-20
i get the following error when running the script provided below  the ciopy part works perfect the move part is the one that gives the error please help

Line 23
Char  2
Error  The system cannot find the file specified.

code 80070002
source (null)

this is the script please help

// Copy compressed backups to backups server then move originals to data folder.
// Plese note: all backslash's must be doubled, this is a becouse of the way Jscript deals with strings

var strPath = "Y:\\TransCompCasino\\";
var strDestPath = "\\\\backups\\DBbackups\\TransCompCasino\\";

var shell = new ActiveXObject("WScript.Shell");
var objFSO = new ActiveXObject('Scripting.FileSystemObject');

var objFolder = objFSO.GetFolder(strPath);
var nrFiles = objFolder.Files.Count;
var collectionFiles = new Enumerator(objFolder.Files);
while (!collectionFiles.atEnd())
   objFile = collectionFiles.item();
   if (objFile.Type == "RAR File")
      strFileName = objFile.Name;
                strCommand = "xcopy " + strPath + strFileName + " " + strDestPath + " /v /d";
      strCommand = "move /y " + strPath + strFileName + " " + strPath + "data\\";
Question by:m3mn0ck
  • 2

Expert Comment

ID: 12515614
Hi m3mn0ck,

print the strcommand to the screen after you've constructed it. this should help you know why it doesnt work.

Author Comment

ID: 12515645
The string is working fine, actually if i just change the Move Comand to Xcopy (of course i remove the /y switch it works fine and copies the files. but it will not move them i get that error even if i run it without the /y switch

Accepted Solution

browolf earned 375 total points
ID: 12516887
have you  tried using proper jscript filesystem object stuff to do the move e.g.

Sub ManipFiles
  Dim fso, f1, f2, s
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
  Response.Write "Writing file <br>"
  ' Write a line.
  f1.Write ("This is a test.")
  ' Close the file to writing.
  Response.Write "Moving file to c:\tmp <br>"
  ' Get a handle to the file in root of C:\.
  Set f2 = fso.GetFile("c:\testfile.txt")
  ' Move the file to \tmp directory.
  f2.Move ("c:\tmp\testfile.txt")
  Response.Write "Copying file to c:\temp <br>"
  ' Copy the file to \temp.
  f2.Copy ("c:\temp\testfile.txt")
  Response.Write "Deleting files <br>"
  ' Get handles to files' current location.
  Set f2 = fso.GetFile("c:\tmp\testfile.txt")
  Set f3 = fso.GetFile("c:\temp\testfile.txt")
  ' Delete the files.
  Response.Write "All done!"
End Sub

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Are you a startup company? Being a startup, you may be using shared hosting, or maybe even dedicated hosting. But have you ever given a thought to using cloud computing now? Yes, don’t be surprised, it is possible for startups to opt for cloud compu…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question