Hopefully "ScriptingTipsAndTricks" helps you with your batch file or vbscript scripting :-)
[Bottom][Contents][Prev]: SortDictionary() - Sorts dictionary objects[Next]: HTML APPLICATIONS (.HTA) & HTML
\->VBSCRIPT Files->TimeStamp() - including files

[anchor]

The Code for: "TimeStamp() [including files].vbs"

This is the example, a shortcut was installed to this code :

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' $Header:   C:/DBAREIS/Projects.PVCS/Win32/ScriptingTipsAndTricks/EXAMPLE[vbs].TimeStamp() [including files].vbs.pvcs   1.0   29 Jun 2014 12:51:24   USER "Dennis"  $
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


'--- Init -------------------------------------------------------------------
dim oFS      : set oFS    = CreateObject("Scripting.FileSystemObject")
dim oShell   : set oShell = CreateObject("WScript.Shell")
dim FileName : FileName   = GetEnv("WINDIR") & "\win.ini"

'--- Test functions ---------------------------------------------------------
wscript.echo FileName
wscript.echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
wscript.echo "NOW()  : " & TimeStamp( now() )
dim oFile : set oFile = oFS.GetFile(FileName)
    wscript.echo "WIN.INI: " & TimeStampFile(oFile)
set oFile  = Nothing
set oFS    = Nothing
set oShell = Nothing

'============================================================================
function TimeStamp(ByVal TimeObject)       'NOTE: These timestamps can't be used in filenames as is
'============================================================================
    on error resume next
    dim TS       : TS       = ""
    TS = TS & Year(TimeObject)         & "/" & Pad0(Month(TimeObject),2)  & "/" & Pad0(Day(TimeObject), 2)    & " "
    TS = TS & Pad0(hour(TimeObject),2) & ":" & Pad0(Minute(TimeObject),2) & ":" & Pad0(second(TimeObject), 2) & " "
    TS = TS & "(" & ucase(WeekDayName(WeekDay(TimeObject), true)) & ")"
    TimeStamp = TS
end function


'============================================================================
function TimeStampFile(ByVal oFile)
'============================================================================
    on error resume next
    TimeStampFile = TimeStamp( oFile.DateLastModified )
end function

'============================================================================
function Pad0(ByVal TheNumber, ByVal TheLength)        'Never truncates
'============================================================================
   dim Lng: Lng = len(TheNumber)
   if  Lng >= TheLength then
       Pad0 = TheNumber
   else
       Pad0 = string(TheLength-Lng, "0") & TheNumber
   end if
end function

'============================================================================
function GetEnv(EnvName)
'============================================================================
   dim Try
   Try    = "%" & EnvName & "%"
   GetEnv = oShell.ExpandEnvironmentStrings(Try)
   if  GetEnv = Try then
       GetEnv = ""
   end if
end function


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: SortDictionary() - Sorts dictionary objects[Next]: HTML APPLICATIONS (.HTA) & HTML


ScriptingTipsAndTricks© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday September 07 2014 at 12:50pm
Visit ScriptingTipsAndTricks's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.