Sign in to follow this  
Followers 0
stuka

....

8 posts in this topic

#1 ·  Posted (edited)

.

Edited by stuka

Share this post


Link to post
Share on other sites



Your question makes no sense.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Let's say I want to delete a certain file like 'autorun.inf'. But before I delete the file, it has to match certain criterias before it is deleted.

For example, if the following strings are found...

open=winword.exe
shellexecute=winword.exe

...then only is the file deleted.

Do i need an .ini file to do this? Then the user can define what criterias to delete right?

"Your question makes no sense."

It makes sense

I made 3 .ini's in C:\inis folder 2 of them had section, key delete and it finds the ones with delete/delete and deletes thoes say you want to also delete inis with delete2/delete2 then duplicate the $read1 line and put it after the 1st if not @error and it will also delete ones with that. All the inis must be in same folder

Hope this helps

#include <File.au3>
Func DeleteIni()
    $FileNum = 0
    $FileList = _FileListToArray("C:\inis", "*", 1)
While 1
If $FileNum = $FileList[0] Then
        MsgBox(0, "Done", "File deletion done")
        Exit
Else
        $FileNum += 1
EndIf
$IniName = "C:\inis\"&$FileList[$FileNum]
$Read1 = IniReadSection($IniName, "Delete")
If Not @error Then
    FileDelete($IniName)
EndIf
WEnd
EndFunc
Edited by frostfel

Share this post


Link to post
Share on other sites

First... Your question didn't make much sense.

You have to realize that help starts with a properly "detailed" question, preferably with code that you've attempted (sometimes the code makes more sense than the poster does).

If it wasn't for Blue Drache at the beginning of my escapades here, I wouldn't have stayed.

*****

How do you expect to read the file if it's not open to check it for the string to begin with?

So, I think the Emperor was pretty much dead on. I'd only change it to reading the whole file, and take out the fileopen, because fileread already does that for you.

'psuedo code':

$sReadFile = FileRead('MyFileName')
If StringInStr($sReadFile, "open=winword.exe") Or StringInStr($sReadFile, "shellexecute=winword.exe") Then FileDelete('MyFileName')

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

You don't think IniRead opens the file to read it? Ever try to read every page of a new book without opening it first?

Anyway.... If you know the Section and the Key you are looking for, that's fine... but if you don't know the section, then just use FileRead.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Haha, that's pretty dumb of me. So a file can be 'invisibly' opened because when IniRead runs, I ain't see no opened file.

Anyways, the script works. You can refer to my completed script above.

On thing though with file reading, I can't remove my pendrive even though 'autorun.inf' in it(i use it to change the drive icon) does not contain any of the aforementioned strings. I guess it must be reading...and reading...the file but i know it can be solved with a simple script 'pause'.

Thanks again for the help. :)

Well you are in a continuous loop, with no condition for TrayGetMsg(), so it's going to check the drives over and over very fast forever. You should probably set the condition to only check when you do something with that TrayGetMsg() :).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

So how do I set the condition for TrayGetMsg()?

Look in the help file for an example?

Search the forum for that exact term for an example?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
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
Sign in to follow this  
Followers 0