Solved

Using File Modified as a variable : Code Request

Posted on 2011-03-22
2
173 Views
Last Modified: 2012-05-11
I'm having a surprising amount of trouble with this, I was able to do this all successfully in VBA, but just couldn't convert it to work in Visual Studio 2008. Ive since lost all my VBA work on the script and was hoping i could get some help from the forum.  

Basically I'm in search for a script that Loops the following 3 processes, i also need it to run from an .exe file or similar with no UI (User Interface) so it constantly runs in the background (This is all to go with a multimedia software):

if file 'c:\X.txt' has been modified equal to or more than 15 minutes ago, then send key R

if file 'c:\X.txt' has been modified equal to less than 5 minutes ago, then turn on numlock light, if not then turn off light.

if file 'c:\X.txt' has been not been modified for the last 4 hours , then send key delete file


Any help would be much appreciated, and i hope to be able to learn alot from this forum in the future.
0
Comment
Question by:kakashisharingun
2 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 35187041
Here some help for your timing


Dim fileName As String
fileName = "X.txt"

if DateDiff(DateInterval.Minute , Now, File.GetCreationTime(fileName)) > 240
   ' send delete file
elseif DateDiff(DateInterval.Minute , Now, File.GetCreationTime(fileName)) > 15
  ' send R-key
else
  ' send numlock ...
end if

Open in new window

0
 
LVL 4

Expert Comment

by:LeDaouk
ID: 35187132
try to use AdvancedFileSystemWatcher to check the file changing issue and fire event after xx minutes
also use Process.Start("aaaa.exe") to run aaaa.exe file
 
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 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

20 Experts available now in Live!

Get 1:1 Help Now