[gptalk] Re: Scripting

  • From: hans straat <hstraat@xxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Thu, 21 Feb 2008 15:25:30 +0000

well start with removing the On Error resume next. that is a dirty way of 
letting your script run no matter what :)
for the rest you lost me a bit. i can read what you want to acomplish but can't 
help you here.


Date: Thu, 21 Feb 2008 10:14:03 -0500From: dave.palombi@xxxxxxxxxxx: 
gptalk@xxxxxxxxxxxxxxxxxxxx: [gptalk] Re: ScriptingWell I have been working on 
this script and I have two final issues with it that I need help with.  The 
first issue is the comparisons  portion.  It always continues on even though 
the files and reg key are updated.  The second part I get an error after it 
completes everything.Code below,Option ExplicitDim strComputer, strMbox, 
ArrDriveType, WMI, coldisks, disk, strtype, strID, strSys, UsbKey, file, 
USBFound, varToday, Verify, LastRunDate, WshShellDim objReg, keypath, return, 
NextSection, oFile, oLastFile, dteFileDate, strFileDateDim objFSO:Set 
objFSO=CreateObject("Scripting.FileSystemObject")Dim objFolderA: Set 
objFolderA=objFSO.GetFolder("\\bluewater\departments$\Information 
Technology\test\")Set WshShell = WScript.CreateObject("WScript.Shell")Set 
WshShell = CreateObject("Wscript.Shell")varToday = Weekday(Date)Verify = 
"HKEY_LOCAL_MACHINE\SOFTWARE\EMERGENCY PLANNING\"On Error Resume 
NextLastRunDate = WshShell.RegRead(Verify & "File\")On Error GoTo 0For Each 
oFile In objFSO.GetFolder("\\bluewater\departments$\Information 
Technology\test\").filesSet oLastFile = oFileNextdteFileDate = 
oLastFile.DateLastAccessedstrFileDate = Month(dteFileDate) & "/" & 
Day(dteFileDate) & "/" & Year(dteFileDate)WScript.Echo "I am comparing " & 
LastRunDate & " TO " & strFileDateIf strFileDate = LastRunDate  AND LastRunDate 
<> "NONE" ThenWScript.QuitEnd If strMbox = "."strMbox = msgBox("Please insert 
your Emergency Planning usb key and press the enter key to continue")If strMbox 
= 1 Then  strmbox ="."end ifstrComputer = "."arrDriveType = array("Unknown",_   
       "No Root Directory",_          "Removable Disk",_          "Local 
Disk",_          "Network Drive",_          "Compact Disk",_          "RAM 
Disk")set WMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")set 
colDisks = WMI.ExecQuery("Select * from Win32_LogicalDisk")For Each Disk in 
ColDisks    strType = arrDriveType(Disk.DriveType)    strID = Disk.DeviceID    
strSys = Disk.SystemName    If strType = "Removable Disk" then          
'strMbox = MsgBox("USB drive letter is " & Disk.DeviceID)          UsbKey = 
strId & "\"          USBFound = True    End IfNextIf USBFound = False Then    
MsgBox "No USB drive was found."    WScript.QuitEnd IfFor Each file in 
objFolderA.Files  'If DateDiff("n", file.DateLastModified, Now) =< 60 Then      
   objFSO.CopyFile file.Path, UsbKey  'End Ifconst HKEY_LOCAL_MACHINE = 
&H80000002strComputer = "."Set 
objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_strComputer & 
"\root\default:StdRegProv")KeyPath = "Software\Emergency Planning\File"Return = 
objReg.CreateKey(HKEY_LOCAL_MACHINE, KeyPath)'Set WshShell = 
WScript.CreateObject("WScript.Shell")WshShell.RegWrite "HKLM\Software\Emergency 
Planning\File\", date()NextMsgBox "All files have sucessfully copied"Set 
objFSO=Nothing 
On Thu, Feb 21, 2008 at 10:11 AM, hans straat <hstraat@xxxxxxx> wrote:

what kind of scripting or in other words what do you want to achive?


Date: Thu, 21 Feb 2008 10:05:14 -0500From: dave.palombi@xxxxxxxxxxx: 
gptalk@xxxxxxxxxxxxxxxxxxxx: [gptalk] Scripting 
I just wanted to know if anyone knows any scripting?  Doesn't hurt to ask.Dave

Other related posts: