Jump to content

filegettime creat text file


Recommended Posts

I would like to create a script to look at the virus signature files and if the modified date on the file is older than a specified date I'd like to create a text file on a network share with the computer name. I could then batch this to look at the sig file and if it's too old I would know the name of the computer that doesn't have an updated signature file. Something like this.

$bootdat = FileGetTime( "C:\Program Files\CA\SharedComponents\ScanEngine\boot.dat", 0)

If $boot = 2007/04/10 Then

Run ( "computername.bat" )

EndIf

The computername.bat is a file I already have created that will create a txt file with the name of the computer. I just don't know how to make the variable here compare the file modified date.

Any help would be great.

Edited by bdorminy
Link to comment
Share on other sites

I would like to create a script to look at the virus signature files and if the modified date on the file is older than a specified date I'd like to create a text file on a network share with the computer name. I could then batch this to look at the sig file and if it's too old I would know the name of the computer that doesn't have an updated signature file. Something like this.

$bootdat = FileGetTime( "C:\Program Files\CA\SharedComponents\ScanEngine\boot.dat", 0)

If $boot = 2007/04/10 Then

Run ( "computername.bat" )

EndIf

The computername.bat is a file I already have created that will create a txt file with the name of the computer. I just don't know how to make the variable here compare the file modified date.

Any help would be great.

Have a look at Date.au3 in the include folder.

There is a function which returns the difference in seconds btween two date times.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Thanks, but I'm not sure how that helps. (not saying it doesn't just not sure how)

I just simply need to be able to check the file date and if it's older than today's date (or specified date) then run my batch file. Maybe it's not as simple as I want it to be.

$bootdat = FileGetTime( "C:\...\ScanEngine\boot.dat", 0)

If $bootdat < April 10th 2007 < ------how do I say less than a specific date here? Will that work?

Then

Run ( "compname.bat" )

EndIf

Edited by bdorminy
Link to comment
Share on other sites

Thanks, but I'm not sure how that helps. (not saying it doesn't just not sure how)

I just simply need to be able to check the file date and if it's older than today's date (or specified date) then run my batch file. Maybe it's not as simple as I want it to be.

$bootdat = FileGetTime( "C:\...\ScanEngine\boot.dat", 0)

If $bootdat < April 10th 2007 < ------how do I say less than a specific date here? Will that work?

Then

Run ( "compname.bat" )

EndIf

Presumably you didn't read Date .au3, and I think you may not have read the help file for FileGetTime.

Here is an example to show you how to use both.

#include <date.au3>
$fd = Filegettime("d:\windows\explorer.exe");or whatever file you are interested in

$filedate = $fd[0] & '/' & $fd[1] & '/' & $fd[2] & ' ' & $fd[3] & ':' & $fd[4] & ':' & $fd[5]
MsgBox(0,'filedate is',$filedate)
;get a date to compare $filedate with
$now = @YEAR & '/' & @MON & '/' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC
;could have said $now = _NowCalc()
MsgBox(0,'now is',$now)
$diff = _DateDiff('s',$filedate,$now)
if $diff = 0 then MsgBox(0,'error is',@error)
msgbox(0,'difference in seconds is',$diff)
$diff = _DateDiff('s',$now,$filedate)
if $diff = 0 then MsgBox(0,'error is',@error)
msgbox(0,'difference in seconds is',$diff)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Presumably you didn't read Date .au3, and I think you may not have read the help file for FileGetTime.

Here is an example to show you how to use both.

Actually I did read both, and they didn't help me solve my problem. I didn't need to know the difference in seconds between 2 date times. I simply wanted to know if the modified date of a file was older than a specific date.

If FileExists ( "c:\...\file.name" ) = 1 Then

If Not @error Then

$yyyymd = $bootdat[0] & "/" & $bootdat[1] & "/" & $bootdat[2]

EndIf

If FileExists ( "c:\...\file.namet" ) = 1 Then

If $yyyymd < "2007/04/02" Then

Run ( "\\etrust\files\oldsig.bat" )

EndIf

This code worked fine once I had all the syntax correct. Thanks for the effort though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...