Keep the app always active
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Keep the app always active
Hi everybody,
I wanna make a script that, while the stack is running, it always delete a text file named "test.txt" from C: drive any time if the text file is created into that drive. What message i've to use to do that? Is any other solution of it?
I wanna make a script that, while the stack is running, it always delete a text file named "test.txt" from C: drive any time if the text file is created into that drive. What message i've to use to do that? Is any other solution of it?
Hi Tareq,
you will need to write a timer and poll for the existence of that file.
in a button
Hth,
Malte
you will need to write a timer and poll for the existence of that file.
in a button
Code: Select all
on mouseUp
set the flag of me to not the flag of me
if the flag of me then startpolling
end mouseUp
on startPolling
if there is a file "c:/path/to/your/file" then
delete file "c:/path/to/your/file"
end if
if the flag of me then send "startPolling" to me in 100 millisecs
end startPolling
Malte
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Hi malte,
Thanks for your reply. It really works. Now I face another problem & that is, the app always running in process even after closing. So I made a new stack with a button to close that application. I made a script of the new btn-
kill process "test.exe"
"test.exe" is the 1st app name. But i cant kill that process. How to do that?
Thanks for your reply. It really works. Now I face another problem & that is, the app always running in process even after closing. So I made a new stack with a button to close that application. I made a script of the new btn-
kill process "test.exe"
"test.exe" is the 1st app name. But i cant kill that process. How to do that?
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
The problem is that while your 'send in time' construct is still running, the application can only close the stack but won't quit the whole application, resulting in a faceless app eating up resources.
The technical term is 'the pendingMessages is not empty'
The easiest solution is to add the following bit to your stack script
HTH,
Jan Schenkel.
The technical term is 'the pendingMessages is not empty'
The easiest solution is to add the following bit to your stack script
Code: Select all
on closeStackRequest
answer "Are you sure you want to close this application?" with "OK" or "Cancel"
if it is "OK" then quit
end closeStackRequest
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Hi Janschenkel,
Thanks for your reply. I've made a app for my pen drive with your script. As the app is always running, if any "autorun.inf" exists in my pen drive, it automatically delete it showing a message. It acts as a anti-virus for my pen drive. I really feel glad and thanks you again.
But I'm facing a little problem and that is, after safely removing of my pen drive, it shows a error message "There is no disk into the drive. Please insert a disk into the drive I:". Drive I: is my pen drive's letter. I can't cancel this error message as it always running.
I just try to find the way not to close my app but it'll never shows any error message after removing of that drive. Pls, I need your help....
Thanks for your reply. I've made a app for my pen drive with your script. As the app is always running, if any "autorun.inf" exists in my pen drive, it automatically delete it showing a message. It acts as a anti-virus for my pen drive. I really feel glad and thanks you again.
But I'm facing a little problem and that is, after safely removing of my pen drive, it shows a error message "There is no disk into the drive. Please insert a disk into the drive I:". Drive I: is my pen drive's letter. I can't cancel this error message as it always running.
I just try to find the way not to close my app but it'll never shows any error message after removing of that drive. Pls, I need your help....
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
You can always test 'the volumes' first to see if the 'I:' drive is still in there, and you should probably test first with 'if there is a file' before you try to read it.
So disable your own anti-virus executable for a minute and make a test stack with a button with the following script
Plug in your stick and click on the button.
Then unplug your stick and click the button again.
If the second click doesn't result in a "There is no disk..." error message, then you can gleen a solution from the above test script.
HTH,
Jan Schenkel.
So disable your own anti-virus executable for a minute and make a test stack with a button with the following script
Code: Select all
on mouseUp
answer the volumes
answer there is a file "I:autorun.inf"
end mouseUp
Then unplug your stick and click the button again.
If the second click doesn't result in a "There is no disk..." error message, then you can gleen a solution from the above test script.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Hi Janschenkel,
Thanks for your reply. After making script with "If there is a file" for my pen drive, it works good and doesn't show the error message.. I've made a another script for my cd rom as there is also autorun.inf file exists some of the cds, they may hold virus. I've made the script -
H: is my cd drive. Porblem is that, after ejecting any cd, it continously shows that error message "There is no disk into the drive. Please insert a disk into the drive H:". In case of pen drive, as after safely removing the drive shows no more, it doesn't show that error message; but in case of cd drive, I face that problem again. Is there any solution to you? Thanks in advance....
Thanks for your reply. After making script with "If there is a file" for my pen drive, it works good and doesn't show the error message.. I've made a another script for my cd rom as there is also autorun.inf file exists some of the cds, they may hold virus. I've made the script -
Code: Select all
on mouseUp
set the flag of me to not the flag of me
if the flag of me then startpolling
end mouseUp
on startPolling
put "H:/autorun.inf" into tfile
if there is a file tfile then
answer "found"
end if
if the flag of me then send "startPolling" to me in 100 millisecs
end startPolling
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
A quick test on my machine doesn't show the same message. Perhaps someone with VBScript knowledge can find a better test to check if there is a CD in the drive...
Jan Schenkel.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
You can use a modified form of the WMI script from the other thread about interrogating drives:
set the following code as the custom property cVBScript of the buttonThat will return a drive letter for any onboard CD ROM or DVD ROM drives, if they have a disk inserted, which has a volume name or volume serial number (so an unreadable or blank recordable disk will not return a drive - but then they won't have an autorun.inf file to check for).
Also bear in mind that this will not actually intercept the autorun.inf file and prevent it running, and if the autorun file is on the disk, then you won't be able to delete it, either, so this script is really a proof of concept in interrogation of drive contents, not a brute-force antivirus.
To globally prevent CD/DVD ROMS from autorunning, you can set the following registry key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\CDRom with the value 0 to disable autorun (or 1 to re-enable it)
set the following code as the custom property cVBScript of the button
Code: Select all
strComputer = "."
result = ""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk where drivetype = 5")
For Each objDisk in colDisks
if objDisk.volumename <> "" or objDisk.volumeserialnumber <> "" then
result = result & objDisk.DeviceID & vblf
end if
Next
Set colDisks = nothing
Set objWMIService = nothing
Code: Select all
on mouseUp
set the flag of me to not the flag of me
if the flag of me then startpolling
end mouseUp
on startPolling
local tFile, tLoadedDriveList
do the cVBScript of me as "vbscript"
put the result into tLoadedDriveList
repeat for each line tDrive in tLoadedDriveList
put tDrive & "/autorun.inf" into tFile
if there is a file tFile then
answer "found"
-- at this point, you may also want to
set the flag of me to false
-- to stop polling while you take action on finding an autorun.inf file
end if
end repeat
if the flag of me then send "startPolling" to me in 100 millisecs
end startPolling
To globally prevent CD/DVD ROMS from autorunning, you can set the following registry key:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\CDRom with the value 0 to disable autorun (or 1 to re-enable it)