mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 set the clock to the day before with a .vbs- thxs TNO

Author Message
n2clarkster

  • Total Posts : 11
  • Scores: 0
  • Reward points : 0
  • Joined: 9/12/2009
  • Status: offline
set the clock to the day before with a .vbs- thxs TNO Wednesday, September 08, 2010 1:52 AM (permalink)
0
http://pastebin.com/3SmfjzcN
#1
    n2clarkster

    • Total Posts : 11
    • Scores: 0
    • Reward points : 0
    • Joined: 9/12/2009
    • Status: offline
    Re:set the clock to the day before with a .vbs- thxs TNO Wednesday, September 08, 2010 3:38 AM (permalink)
    0
    A Microsoft example of how to set the time to 2004 would be done like so which indicates there is a way to subtract a day
    http://technet.microsoft.com/en-us/library/ee692591.aspx
     
    On Error Resume Next
     
    strComputer = "."
    dtmNewDateTime = "20040520151300.000000-480"
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate, " _
     & "(Systemtime)}!\\" & strComputer & "\root\cimv2")
    Set colOSes = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
     
    For Each objOS In colOSes
      intSet = objOS.SetDateTime(dtmNewDateTime)
      If intSet = 0 Then
        Wscript.Echo "Successfully set new date and time."
      Else
        Wscript.Echo "Unable to set mew date and time."
      End If
    Next
     
    Set colOSes = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")
    For Each objOS In colOSes
      Wscript.Echo "New date and time: " & WMIDateToString(objOS.LocalDateTime)
    Next
     
    '******************************************************************************
     
    Function WMIDateToString(dtmDate)
    WMIDateToString = CDate(Mid(dtmDate, 5, 2) & "/" & _
                      Mid(dtmDate, 7, 2) & "/" & _
                      Left(dtmDate, 4) & " " & _
                      Mid(dtmDate, 9, 2) & ":" & _
                      Mid(dtmDate, 11, 2) & ":" & _
                      Mid(dtmDate, 13, 2))
    End Function
    #2
      rasimmer

      • Total Posts : 2360
      • Scores: 163
      • Reward points : 0
      • Joined: 3/19/2009
      • Location: Cedar Rapids, IA
      • Status: offline
      Re:set the clock to the day before with a .vbs- thxs TNO Wednesday, September 08, 2010 4:27 AM (permalink)
      0
      You can use WbemScripting.SWbemDateTime (http://msdn.microsoft.com/en-us/library/aa394590(VS.85).aspx) to convert and manipulate the dates.  I believe it has a way to manipulate time\date with addition\subtraction as well.

      I don't know why you are setting the date incorrectly, but you will not be able to log into an Active Directory domain if the computer time is 10 minutes diffrent from the AD controller.  In addition, the Windows Time service will automatically sync (if the computer is part of domain) the time and fix it.
      #3
        n2clarkster

        • Total Posts : 11
        • Scores: 0
        • Reward points : 0
        • Joined: 9/12/2009
        • Status: offline
        Re:set the clock to the day before with a .vbs- thxs TNO Friday, September 10, 2010 4:43 AM (permalink)
        0
        Thxs rasimmer I finally found what I was after for the report
         
        to subtract 1 day
        dtmNewDate = Date - 1
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run("%comspec% /c date " & dtmNewDate)
         
        to add 1 day
         
        dtmNewDate = Date + 1
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run("%comspec% /c date " & dtmNewDate)
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.8
          mbt shoes www.wileywilson.com