[gptalk] Re: Scripting

  • From: "Dave Palombi" <dave.palombi@xxxxxxxxx>
  • To: gptalk@xxxxxxxxxxxxx
  • Date: Thu, 21 Feb 2008 10:14:03 -0500

Well 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 Explicit
Dim strComputer, strMbox, ArrDriveType, WMI, coldisks, disk, strtype, strID,
strSys, UsbKey, file, USBFound, varToday, Verify, LastRunDate, WshShell
Dim objReg, keypath, return, NextSection, oFile, oLastFile, dteFileDate,
strFileDate
Dim 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 Next
LastRunDate = WshShell.RegRead(Verify & "File\")
On Error GoTo 0

For Each oFile In objFSO.GetFolder("\\bluewater\departments$\Information
Technology\test\").files
Set oLastFile = oFile
Next

dteFileDate = oLastFile.DateLastAccessed

strFileDate = Month(dteFileDate) & "/" & Day(dteFileDate) & "/" &
Year(dteFileDate)

WScript.Echo "I am comparing " & LastRunDate & " TO " & strFileDate

If strFileDate = LastRunDate  AND LastRunDate <> "NONE" Then
WScript.Quit
End If

strMbox = "."

strMbox = msgBox("Please insert your Emergency Planning usb key and press
the enter key to continue")

If strMbox = 1 Then

  strmbox ="."

end if

strComputer = "."


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 If

Next

If USBFound = False Then
    MsgBox "No USB drive was found."
    WScript.Quit
End If

For Each file in objFolderA.Files
  'If DateDiff("n", file.DateLastModified, Now) =< 60 Then
         objFSO.CopyFile file.Path, UsbKey
  'End If


const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
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()

Next

MsgBox "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 -0500
> From: dave.palombi@xxxxxxxxx
> To: gptalk@xxxxxxxxxxxxx
> Subject: [gptalk] Scripting
>
> I just wanted to know if anyone knows any scripting?  Doesn't hurt to ask.
>
> Dave
>
>

Other related posts: