VBScript syntax error

Discussion in 'Software' started by Kniht, Apr 20, 2006.

  1. Kniht

    Kniht Sergeant

    Since my PC has very little idle time, I decided to run a .vbs at initial boot of the day to create a restore point.

    I get a syntax error message:

    Line: 1
    Character: 17

    Does anyone know what needs to be corrected in the following script:

    Option Explicit
    Dim SRP, CSRP, objWMI, clsPoint
    Dim RPDate, D1, D2, dtmInstallDate, DMatch
    DMatch = 0
    Set SRP = getobject("winmgmts:\\.\root\default:Systemrestore")
    Set dtmInstallDate = CreateObject("WbemScripting.SWbemDateTime")
    Set objWMI = getobject( _
    "winmgmts:\\.\root\default").InstancesOf ("systemrestore")
    For Each clsPoint In objWMI
    RPDate = getmytime(clsPoint.creationtime)
    D1 = Month(RPDate) & "/" & Day(RPDate) & "/" & Year(RPDate)
    D2 = Month(Date) & "/" & Day(Date) & "/" & Year(Date)
    If D1 = D2 Then DMatch = 1
    Next
    Function getmytime(wmitime)
    dtmInstallDate.Value = wmitime
    getmytime = dtmInstallDate.GetVarDate
    end Function
    If DMatch = 0 Then
    CSRP = SRP.createrestorepoint ("Daily Restore Point", 0, 100)
    End If

    Any help will be greatly appreciated.
     
  2. Mada_Milty

    Mada_Milty MajorGeek

    There's nothing wrong with the syntax of this script. I copied it and ran it, and things went flawlessly. The error message you're receiving must be in error (its hard to mess up that option explicit line )

    Is this the entire script? You don't have comments or anything at all preceeding this?
     
  3. Kniht

    Kniht Sergeant

    Mada Milty

    That is the entire script I try to run. I have "AnalogX Script Defender" on my PC so when the script tries to run, I am asked if I want to run this script or block it. After I press "execute script" is when I get the error message.

    I disabled "Script Defender" and tried on a reboot to run the script. I got no error message, but the script didn't run at all.

    Any ideas as to why this happened?
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds