Solved

Shadow Copy VBScript Changes

Posted on 2013-12-02
2
363 Views
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"
'Else
   '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
        Else
           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
      obj.Delete_()
        End If
     Next
  End If[embed=file 690800]

Open in new window

Untitled.png
0
Comment
Question by:afsfire
2 Comments
 
LVL 12

Accepted Solution

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

Author Closing Comment

by:afsfire
ID: 39699265
Looks like that was the answer. Thanks!
0

Featured Post

Do email signature updates give you a headache?

Are you constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now