GET-IT: TEAMS DAY | 1-Day Free Virtual Conference all about Teams. Here on Petri.com - 8/12/20 GET-IT: TEAMS DAY - 8/12/20

Need help adding a progess bar to code

Home Forums Scripting Windows Script Host Need help adding a progess bar to code

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    vane0326
    Member
    #165273

    Hi everyone,

    Just to let everyone know that my original account “Shazam” is somehow not working. I’m not able to logon. I sent a private message to the Administrator regarding this issue. In the meanwhile I created another account so I can post a question here. Hopefully I’m not offending anyone.
    Back to my question…

    I have this VBScript below. It will copy a folder from the source location and paste it to any USB flash drives that is connect to your computer simultaneously. This actually works pretty well. The only thing it doesn’t have is a progress bar. Is it possible to add to the code?

    I’ve found these 2 links below. That shows how to add a progress bar but I wasn’t able to get it to work with the existing code.

    I would like to use the” Windows Shell object” if possible.

    https://technet.microsoft.com/en-us/…/ee176633.aspx

    http://blogs.technet.com/b/heyscript…ing-files.aspx

    Code:
    sFolderToCopy = “C:Test”

    Set oFS = CreateObject(“Scripting.FileSystemObject”)
    Set dUSBKeys = ScanForUSBKeys()

    For Each oUSBKey in dUSBKeys.Keys
    If Left(oUSBKey, 1) = “” Then
    sKey = oUSBKey
    Else
    sKey = oUSBKey & “”
    End If

    oFS.CopyFolder sFolderToCopy, sKey

    Next

    Set dUSBKeys = Nothing
    Set oFS = Nothing

    Msgbox “Done.”

    Function ScanForUSBKeys()
    Set oWMI = GetObject(“winmgmts:\.rootcimv2”)
    Set dTemp = CreateObject(“Scripting.Dictionary”)

    Set cDisks = oWMI.ExecQuery(“Select InterfaceType,MediaType,PNPDeviceID,DeviceID,Size from Win32_DiskDrive”)
    For Each oDisk in cDisks
    If InStr(LCase(oDisk.InterfaceType),”usb”) > 0 AND InStr(LCase(oDisk.MediaType),”removable”) > 0 _
    AND InStr(LCase(oDisk.PNPDeviceID),”blackberry”) = 0 AND InStr(LCase(oDisk.PNPDeviceID),”ipod”) = 0 _
    AND NOT oDisk.PNPDeviceID = “” Then
    Set cDrivePartitions = oWMI.ExecQuery(“ASSOCIATORS OF {Win32_DiskDrive.DeviceID='” & _
    oDisk.DeviceID & “‘} WHERE AssocClass = Win32_DiskDriveToDiskPartition” )
    For Each oDrivePartition in cDrivePartitions
    Set cDriveLetters = oWMI.ExecQuery(“ASSOCIATORS OF {Win32_DiskPartition.DeviceID='” & _
    oDrivePartition.DeviceID & “‘} WHERE AssocClass = Win32_LogicalDiskToPartition”)
    For Each oDriveLetter in cDriveLetters
    dTemp.Add oDriveLetter.DeviceID, 1
    Next
    Set cDriveLetters = Nothing
    Next
    Set cDrivePartitions = Nothing
    End If
    Next
    Set cDisks = Nothing
    Set ScanForUSBKeys = dTemp
    Set dTemp = Nothing
    Set oWMI = Nothing
    End Function

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.