Friday, January 25, 2008

calling an external script and passing back a result

Maxthon plugins are known to be able to use features which are normally restricted in regular embeded page script. However, even a plugin has it's limitations. One of those limitations is working with the WMI interface.


There is however a method to get around this limitation. Plugins are allowed to use most all ActiveX objects, and two of the most commonly used are the Windows Script Host and the File System Object. The solution is to place all WMI related script in an external file, separate from the regular plugin code. Then you simply use WSH to run this external script.


But what if you need access to results produced by the called script? Again there's likely more methods, but I found two methods to be most useful. If the result is only a single, numeric value, the easiest woulld be to pass the return value though the WSH exitcode.


In your plugin you then assign the result of the WSH call to a variable which you can test to have your plugin take action accordingly


testResult = oWSH.Run(<plugin.path>ExternalScript  [arguments] , 0 , false)


in the ExternalScript file (js or vbs) you then include as last execution line something like


Wscript.Quit(myReturnCode) (possible values range from 0 to 255)





Another method would be to have your external script place the results in a text file and then have your plugin parse this textfile after the call to the external script (thanks to abc@home for this last tip)

Labels: ,

Friday, January 18, 2008

NirSoft

For those of you already aware of the existance of http://nirsoft.net  there's been some new updates and releases. If you haven't visited the site recently, do so now. For those of you not knowing the site, it's loaded to the hilt with all kinds of nice tools and utilities ABSOLUTELY FREE. Definitely worth a look see.

Revival

Yikes it has been a long time since I last posted something here... Well, see how long I can keep it up this time.



Decided a small course change for this blog. Instead of using it to post stuff others might find useful, I'm gonna post stuff I find useful. Like ventilating my frustrations about how folks sometimes behave when visiting a forum...



Usually you get to meet a lot of nice, friendly people, sincerely trying to find a solution for their problem. One thing that never stops to amaze me is the ignorance and backtalk you sometimes get from a visitor who desperately wants it his/her way and just refuses to see what is right in front of him/her? Yep, forcing horses to drink is still impossible...it is sometimes downright de-motivating. It gets especially worse if the visitor doesn't speak English but instead is relying on an online translation service to get his/her question on the board.



The risk of course being that the translation ends up having you say something that you didn't. Which works both ways of course, it also could have the visitor post something offending completely unintentional. Now, English not being my native language either, I too sometimes don't 'get it' at the first attempt. Usually this gets corrected pretty quick in the same topic, but sometimes...However, what do you do if a visitor puts words in your mouth you never said, and on top of that accuses you of something that completely missed the point by a giga-mile?



Normally you give such a user a little heads up, if it doesn't help you get a little stricter, and sometimes you end up using even stronger measures. (such as having your posts needing approval) Recently I got faced with such a situation. Visitor asks a question about which values a certain setting understands when directly editing config files. Well, this was even too geeky for me as I'd simply would press the button and be done with it, why doing it the hard way by manual edit? So I suggested to take the other way around thinking that the visitor would have not too much problems getting this translated.



Much to my surprise this person responds by starting name calling. Being human like the rest of us I wasn't gonna stand for this. This being the proverbial drop I placed this visitor on probation. At which point a repost of the same question appears, again accompanied by innuendo and false accusations. Did I ask myself if I made the right call? Of course I did, don't you ever second guess your own decisions? In this case, knowing there was a language barrier, I was even planning on giving the visitor the benefit of the doubt up until a couple of hours later when a topic appeared from a so-claimed coworker, tryin to ' mediate' . Again, this person too demonstrates a complete lack of understanding plain English by just ignoring what one of the admins responds with. and continuing to ignore the few simple rules in place



Mod decisions are not open to discussion
Personal attacks not allowed in public.



What makes me feel ambivalent is that this wouldn't have happened if only the visitor had been aware of his/her limitations in understanding what got said. As a result things got said that simply were unacceptable and downright incorrect, (and suddenly there was enough language knowledge to start name calling). What rattled my cage more was the refusal to personally deal with the situation afterwards and instead letting someone else try to pick the marshmellows out of the fire...



So please folks, if you ever visit a forum and you need a translator to read what it is all about, please find in your social circle someone who does speak/read/write the language at least enough to prevent such pittfalls.



Oh, and if there's anyone out there who knows of a forum where Maxthon is discussed in Brazilian Portuguese, drop me a line...