Jump to content


  • Posts

  • Joined

  • Last visited

Juz's Achievements


Newbie (1/7)



  1. Hello everyone I'm pretty new to vbscript but I'm trying to make a script to check usb drives have been changed for backups. This script bellow works fine when I double click it but when I use cscript.exe or wscript.exe and even WHS it runs through the script but does not execute the code except for WScript.Echo "Worked"??? Set obj = CreateObject("Scripting.FileSystemObject") Set objTextFile = obj.OpenTextFile("C:\purplec\BackupCheck\ListDrives.txt",1) For i = 1 to 84 objTextFile.ReadLine Next strLine = objTextFile.ReadLine objTextFile.Close If (obj.FileExists("disk1.txt")) Then Set objWriteFile = obj.OpenTextFile("disk2.txt",2,true) objWriteFile.WriteLine strLine objWriteFile.CloseElseSet objWriteFile = obj.OpenTextFile("disk1.txt",2,true) objWriteFile.WriteLine strLine objWriteFile.CloseEnd If If (obj.FileExists("disk2.txt")) Then Set objTextFile = obj.OpenTextFile("disk1.txt",1) strLine1 = objTextFile.ReadLine objTextFile.CloseSet objTextFile = obj.OpenTextFile("disk2.txt",1) strLine2 = objTextFile.ReadLine objTextFile.CloseIf strLine1 = strLine2 Then Set objWriteFile = obj.OpenTextFile("NotChanged.txt",2,true) objWriteFile.WriteLine strLine1 objWriteFile.WriteLine strLine2 objWriteFile.CloseElse Set objWriteFile = obj.OpenTextFile("Changed.txt",2,true) objWriteFile.WriteLine strLine1 objWriteFile.WriteLine strLine2 objWriteFile.Close Set objWriteFile = obj.OpenTextFile("disk1.txt",2,true) objWriteFile.WriteLine strLine2 objWriteFile.CloseEnd IfEnd IfWScript.Echo "Worked" Thanks in advance
  • Create New...