Shadow Copy VBScript Changes

Posted on 2013-12-02
Medium Priority
Last Modified: 2013-12-05
I have moved my file server from Windows 2003 (32bit) to a new Windows 2012 R2 Server (x64).

I run a Shadow Copy once per hour on this server and have a script that manages the Shadow Copies quite well. However, when I moved the Script to the new server obviously I have some issues with it. here is the script as it was, as well as the error I get when I try to run it. Hoping someone could help with the changes needed to work on the new server.

Option Explicit
Dim nameSpace
Dim objSet
Dim dateTime
Dim vDate
Dim obj
Dim age
Dim Time, AmPm, Hour
Dim aParts
If Hour >= 18 Then
   Msg = "  This occurred after 6 PM"
   'Msg = "  This occurred before 6 PM"
End If
  Set dateTime  = CreateObject("WbemScripting.SWbemDateTime")
  Set nameSpace = GetObject("winmgmts://localhost/root/cimv2")
  Set objSet    = nameSpace.ExecQuery("select * from Win32_ShadowCopy")
  If objSet.Count > 0 Then
     For Each obj In objSet
        dateTime.Value = obj.InstallDate
        vDate  = dateTime.GetVarDate(True)
        aParts = Split(vDate, " ")
        Time   = aParts(1)
        AmPm   = aParts(2)
        aParts = Split(Time, ":")
        If AmPm = "PM" Then
           Hour = aParts(0) + 12
           Hour = aParts(0)
        End If
        'WScript.Echo "- Snapshot on " & obj.VolumeName & " @ " & vDate
        age = DateDiff("d", vDate, Date)
        If age > 3 And Hour <> 18 Then
           'WScript.Echo "[Deleting snapshot...] for " & obj.Caption & " created on " & vDate
        End If
  End If[embed=file 690800]

Open in new window

Question by:Bill Warren
LVL 12

Accepted Solution

mlongoh earned 2000 total points
ID: 39690542
You are likely having a problem with UAC.  Try disabling it.

Author Closing Comment

by:Bill Warren
ID: 39699265
Looks like that was the answer. Thanks!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
AngularJS web development a very simple procedure. So, to put it, in short, AngularJS’ stand out features are – Two-way data binding, MVC structure, directives, templates, dependency injections and testing.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

623 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