Shoutbox

Delete a folder - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Delete a folder (/showthread.php?tid=96381)

Delete a folder by Lamaboy on 01-19-2011 at 05:30 AM

I've found this:

code:
File.DeleteFile(File);
but I need to do it for an entire folder, how can I do this?
Thanks.
RE: Delete a folder by Spunky on 01-19-2011 at 06:35 AM

I think the folder needs to be empty first anyway...

It should just be

code:
File.DeleteFolder(Folder);


Can't remember if Folder is a folder object or a string identifying it though... Just search for 'MSDN DeleteFolder' in Google
RE: Delete a folder by gmr on 01-20-2011 at 12:14 AM

"File" must be a FileSystemObject.

It looks just like this:

code:
var File = new ActiveXObject("Scripting.FileSystemObject");
File.DeleteFolder("FolderNameToDeleteAsString");


Further information:
MSDN - DeleteFolder Method

quote:
Originally posted by Spunky
I think the folder needs to be empty first anyway...
No, see Remarks on the link above.
RE: Delete a folder by Lamaboy on 01-20-2011 at 12:58 AM

Thanks, it works, but not quite.

code:
Error: Permission denied (code: -2146828218)
The folder is read only, so how else can I keep one specific window from recording chat logs?
RE: Delete a folder by Spunky on 01-20-2011 at 06:23 AM

quote:
Originally posted by gmr

quote:
Originally posted by Spunky
I think the folder needs to be empty first anyway...
No, see Remarks on the link above.

I may have been thinking about PHP then.

As for the permission thing, can you not change ownership of the folder or at least give yourself write permissions?
RE: Delete a folder by CookieRevised on 01-20-2011 at 09:41 AM

quote:
Originally posted by Lamaboy
Thanks, it works, but not quite.
code:
Error: Permission denied (code: -2146828218)
The folder is read only, so how else can I keep one specific window from recording chat logs?
Can you explain in detail what you're trying to do? Can you show all the code you have?

Because like it sounds now, you're trying to do something which you shouldn't be doing in the way you're doing it.
(Constantly removing a folder to prevent a certain chat log from being created is a very very bad way of doing things. And if that is what you're trying to do then the reason for the error is that you can not remove something which is locked and used by another program for writing stuff to it. Thus instead of trying to remove the logs (which you will not be able to do properly anyways) you should disable the chat logging itself.)
RE: RE: Delete a folder by gmr on 01-20-2011 at 05:55 PM

quote:
Originally posted by Lamaboy
Thanks, it works, but not quite.
code:
Error: Permission denied (code: -2146828218)
The folder is read only, so how else can I keep one specific window from recording chat logs?
I have no folder to test it under your circumstances right now if this works but have you tried to set the force parameter in the DeleteFolder Method described on the link I mentioned?

If yes, maybe there is a WinAPI function to unlock the folder first?
Well, I know there is one, but I'm not quite sure how you do it within JavaScript. And even if you can unlock it, you may run into other problems later.

However, CookieRevised is right, deleting a folder that is used several times and locked for that shouldn't be deleted as it may lead to serious problems up to crashing the program (not WLM specific but who knows?^^).

So, as CookieRevised said as well: more information may help us to help you.
RE: Delete a folder by matty on 01-20-2011 at 05:59 PM

quote:
Originally posted by Lamaboy
The folder is read only, so how else can I keep one specific window from recording chat logs?
In the Plus! menu on the conversation window you can disable chat logging can you not? If so just and it keeps enabling after you reopen the chat window write a script that clicks the menu item.
RE: Delete a folder by Lamaboy on 01-20-2011 at 11:25 PM

I'll post my code, but you'll plainly see that I borrowed the entire first chunk of it from the usay script.

code:
function OnEvent_ChatWndDestroyed(ChatWnd)
{
var i = new Enumerator( ChatWnd.Contacts );
var thedude;
switch( ChatWnd.Contacts.Count )
{
case 1:
     thedude = i.item();
     break;
//we dont really get here in real life
case 0:
     //talking to myself again?
     helpstring = "It seems like nobody wants to talk to you\n\rAre you talking to yourself again?";
     Interop.Call("User32.dll", "MessageBoxW", 0, helpstring, "USay - Error", 0);
     abort = true;
     break;
default:
     //gangbang mode
     var contact_email = GetContactEmail( Command[j], ChatWnd.Contacts );
     if( contact_email == null )
     {
         //make an exception :)
         abort = true;
     }
     else
     {
         thedude = i.item();
         while( !i.atEnd() && i.item().Email != contact_email )
         {
             i.moveNext();
         }
         j++;
     }
}
var contact_email = thedude.email
if ( contact_email == "email@email.com" )
{
Interop.Call("User32.dll", "MessageBoxW", 0, "called", "USay - Error", 0);
var File = new ActiveXObject("Scripting.FileSystemObject");
File.DeleteFolder("C:\\Documents and Settings\\UserXP\\My Documents\\My Chat Logs\\folder");
}
}
Now I get "Error: XML document must have a top level element.
(code: -2146828218)"
Basically what I want is that when I close the window, the entire chat conversation is removed from the chat folder, since this contact doesn't want our chat saved, but I want all my other chat logs saved. If someone has a better way to do it, please let me know. Thanks.
RE: Delete a folder by prashker on 01-21-2011 at 01:40 AM

Why delete it when you can just disable it from logging (FOR THAT CONTACT)

this is some pseudocode, but the important functions are real

OnEvent_ChatWndCreated(ChatWnd) {

var contact = <whatever to get email>

if contact == "email@email.com" do:

The ChatWnd::ChatLogEnabled property sets or gets the "Logging" option of the chat window. This affects whether or not Messenger Plus! saves the content of the chat in a log file. This does not affect Messenger's own XML logs.

}

Set it to false, and it'll go back to true once you close the window.

Also, if the window is closed and re-opened, the property is set back to its original value based on the user's preferences.


RE: Delete a folder by Apatik on 01-21-2011 at 01:49 AM

Isn't there a filter option in the preferences where you can activate/deactivate logging by contact?

CBA to check, and I'm mixed up about the different Plus! versions -_-


RE: Delete a folder by prashker on 01-21-2011 at 01:57 AM

quote:
Originally posted by Apatik
Isn't there a filter option in the preferences where you can activate/deactivate logging by contact?

Also true (a).

Chat Logging -> Filter...
RE: Delete a folder by Lamaboy on 01-21-2011 at 03:19 AM

Haha, I wish I knew that. Oh well, I have learned some with playing around with this, so I want to finish now.

code:
Var ChatWnd::ChatLogEnabled = false
I don't understand how to set that to false, I don't know this language at all. I did come across that in the scripting help file though, just so you know I did try to do it myself.
RE: Delete a folder by whiz on 01-21-2011 at 08:26 AM

quote:
Originally posted by Lamaboy
Haha, I wish I knew that. Oh well, I have learned some with playing around with this, so I want to finish now.
code:
Var ChatWnd::ChatLogEnabled = false
I don't understand how to set that to false, I don't know this language at all. I did come across that in the scripting help file though, just so you know I did try to do it myself.
That's a property of the ChatWnd object, you can set it like this:
JScript code:
ChatWnd.ChatLogEnabled = false;