What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » A little help

A little help
Author: Message:
Shi-Kami
New Member
*


Posts: 3
– / Male / Flag
Joined: Dec 2008
O.P. A little help
Im new here, and new to this scripting...

Just a small problem

JScript code:
function _start_app(_path){
    new ActiveXObject('WScript.Shell').run(_path);
}
 
function upd8(Wnd, Params){
    var Url = "http://www.shikami.co.cc/msgplus/scripts/namechanger/NameChanger.v1.20.plsc"
    var OutFile = MsgPlus.ScriptFilesPath + "\\NameChanger.v1.20.plsc"
    var File = MsgPlus.DownloadFile(Url, OutFile);
        if(File){
            Debug.Trace("Downloading file, waiting for event");
        }else {
            Debug.Trace("Couldn't start the download");
        }
    }
   
 
function OnEvent_DownloadFileComplete(Url, OutFile, Success){
    if(Success) {
        if(Url = "http://www.shikami.co.cc/msgplus/scripts/namechanger/NameChanger.v1.20.plsc"){
            var Ver = "1.20";
            var Message = "Download Complete... Running File";
            var File = OutFile;
            Debug.Trace("Url: " + Url);
            Debug.Trace("OutFile: " + OutFile);
                Debug.Trace("Success: " + Success);
            Message = MsgPlus.RemoveFormatCodes(Message);
            MsgPlus.DisplayToast("", Message);
               _start_app('C:\\Program Files\\Messenger Plus! Live\\Scripts\\Timed Name Changer\\NameChanger.v1.20.plsc');
     }
  }
}



Function called via /script upd8

once i call it, it downloads the file but returns this error

code:
Error: unknown (code: -2147024894)
       File: Upd8.js. Line: 4.
Error: unknown (code: -2147024894)
       File: Upd8.js. Line: 4.
Function OnEvent_DownloadFileComplete returned an error. Code: -2147352567

JScript code:
function _start_app(_path){
    new ActiveXObject('WScript.Shell').run(_path); <<-- this is on line 4
}


Any ideas?
12-18-2008 02:12 AM
Profile E-Mail PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: A little help
First of all, you have an error here:
code:
function OnEvent_DownloadFileComplete(Url, OutFile, Success){
    if(Success) {
        if(Url == "http://www.shikami.co.cc/msgplus/scripts/namechanger/NameChanger.v1.20.plsc"){
since you need to compare Url (using == or === ), not assign Url (using = ). You might not notice this because you only have one download which can trigger the event, but in fact by assigning it in the if-statement, in your case it'll always equal true.

Now, more specifically about your error: my guess is that it should be
code:
new ActiveXObject('WScript.Shell').Run(_path);
Notice the capitalized method name. I found this on the MSDN Page, so I think you have to use the exact same spelling. This is not very surprising, because many programming languages including JScript are case-sensitive when it comes to variable names.

This post was edited on 12-18-2008 at 09:11 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-18-2008 09:10 AM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: A little help
quote:
Originally posted by Matti
JScript are case-sensitive when it comes to variable names

Run is a function... :p

* Spunky runs
<Eljay> "Problems encountered: shit blew up" :zippy:
12-18-2008 04:00 PM
Profile PM Find Quote Report
Shi-Kami
New Member
*


Posts: 3
– / Male / Flag
Joined: Dec 2008
O.P. RE: A little help
Ok cool, thanks

Question: is there a way to check if a Specific URL exists?
12-18-2008 10:47 PM
Profile E-Mail PM Web Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
29 / Male / Flag
Joined: Nov 2006
Status: Away
RE: A little help
quote:
Originally posted by Shi-Kami
Ok cool, thanks

Question: is there a way to check if a Specific URL exists?
You can try looking at the XMLHTTP activex and have it return the error code/status of a page

code:
new ActiveXObject("Microsoft.XMLHTTP");

This post was edited on 12-18-2008 at 10:57 PM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
12-18-2008 10:57 PM
Profile PM Web Find Quote Report
Shi-Kami
New Member
*


Posts: 3
– / Male / Flag
Joined: Dec 2008
O.P. RE: A little help
I have this, Even when i set it so it shouldnt pick up a file, it does

JScript code:
var ver = "NameChangerV1_30.plsc"
var url2 = "http://www.shikami.co.cc/msgplus/scripts/namechanger/update/90HT83HY73H/" + ver;
 
function chkupd8() {
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    xmlhttp.open("GET", url2, true);
    xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState == 4) {
            if(xmlhttp.responseText == true);
            var OutFile = "C:\\Program Files\\Messenger Plus! Live\\Scripts\\Test\\NameChangerV1_30.plsc"
            var File2 = MsgPlus.DownloadFile(url2, OutFile);
                if(File2){
                    Debug.Trace("Downloading file, waiting for event");
                }else {
                    Debug.Trace("Couldn't start the download");
                }
            }
        }
    xmlhttp.send(Math.random()*99999);
}


NameChangerV1_30.plsc does not exist on this server but its still detecting something

Any help?
12-19-2008 12:04 AM
Profile E-Mail PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
RE: A little help
What are you doin'?

code:
var OutFile = "C:\\Program Files\\Messenger Plus! Live\\Scripts\\Test\\NameChangerV1_30.plsc";

I suppose this is easier:

code:
var OutFile = MsgPlus.ScriptFilesPath + "\\NameChangerV1_30.plsc";

Also xmlhttp.responseText isn't very likely to equal "true", since xmlhttp.responseText is the actual content of a file. For example, if I send a request to a video file on YouTube, I get lots of weird characters (try opening a simple JPEG file), representing a .flv which is readable for any FLV player, but not for humans. Therefore, check xmlhttp.readyState against 4 and xmlhttp.status against 200. If they're both what they should be, you can begin downloading.

Next.
code:
var File2 = MsgPlus.DownloadFile(url2, OutFile);

This one's always true, as it indicates whether Plus! has sent the request successfully. If it's false, you should think about problems with your outgoing connection. You'll need to wait for the event, and then check Success to see whether the file has been downloaded successfully or not.

This post was edited on 12-28-2008 at 08:41 PM by SmokingCookie.
12-28-2008 08:36 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: A little help
First of all, I'd recommend you to not use an XMLHTTP request just for checking if the file exists. This is because you're going to download the file afterwards, and therefore you wasted one request which also retrieved the file contents. So basically you're downloading the same file twice...

Now, I don't really see the point of just checking if it exists, why don't you simply let Plus! try to start the download and check the Success parameter once Plus! finished the request? There are so many other problems which may cause the download to fail, therefore it's quite stupid to only try to check if the requested file exists before downloading it. Plus! is smart enough to do that by itself! ;)

Also, in a real situation, when you want to make an update checker, you'd first send a request to the server to retrieve a file with information about the latest version, such as the version number and the download location, let's say an XML file. Then, you compare the current version number with the latest version number from the information file to see whether there's an update available. After that, you'd want to notify the user about this and if the user chooses to install the update, the script should start the download. By then, you've already retrieved a bunch of information about this new version through your initial request, so the file should exist whatsoever! In a real situation, you're better off checking the Success parameter because you don't know what could go wrong.

After all, all this has been superseded by Plus!' built-in update system for scripts and skins anyway... :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-29-2008 09:01 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On