What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » experimenting with Wscipt.shell

Pages: (3): « First « 1 [ 2 ] 3 » Last »
experimenting with Wscipt.shell
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: experimenting with Wscipt.shell
Yes, you can create a script which reads the output of shelled commands (commands executed in a so called 'DOS box'). You could use some command line redirection 'tricks' or you could Windows APIs to do the job (better, more robust way). But that wont be easy to understand if you're not an experienced scripter though.

For example, to shut down your computer, instead of executing an external program (which you're not certain it will exist on the system, plus it is limited in what it can do), you can call the Windows API ExitWindowsEx, or InitiateSystemShutdownEx, etc. The possible Windows APIs to be used are listed here.

Also, in many cases, when people ask for something like that (how to read the ouput of external commands), there are many times better solutions which do not involve running a 'DOS box'. You better avoid 'DOS boxes' if you can.

So, what are you attempting to do or what is the reason behind asking that question?


This post was edited on 03-31-2010 at 11:34 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-31-2010 11:13 AM
Profile PM Find Quote Report
scripto
New Member
*


Posts: 14
30 / – / Flag
Joined: Jan 2010
O.P. RE: experimenting with Wscipt.shell
just wanna create something looks like telnet or SSH
remote shell if you want to say
can i get some help or maybe some links to read in ?
P.S the link you provided abt the API's is not working
03-31-2010 07:52 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: experimenting with Wscipt.shell
quote:
Originally posted by scripto
just wanna create something looks like telnet or SSH
remote shell if you want to say
can i get some help or maybe some links to read in ?
That would be extreme hard to do. If not, a lot of work.

By creating something like that you're reinventing the wheel. Why not simply install a remote desktop program (or use the build in remote desktop function in Messenger/Windows)? It will do everything you which for and more.

quote:
Originally posted by scripto
P.S the link you provided abt the API's is not working
There is no alternative link; the link is correct. Make sure you aren't blocking some sites in your browser or firewall, etc.

;)

This post was edited on 04-01-2010 at 02:40 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-01-2010 02:37 AM
Profile PM Find Quote Report
scripto
New Member
*


Posts: 14
30 / – / Flag
Joined: Jan 2010
O.P. RE: experimenting with Wscipt.shell
mmm nahh i just need to know how to read th result of the dos box and the rest will be little bit easy i may be new with JScript but i have some experience with C/C++ and java
just need the result thing any help on that
and abt the link :s i think my pc is infected by kinda of a worm blocking such sites :S security site aren't opening as well :/

so any alternate site o anything the result thingy ?
04-01-2010 05:57 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: experimenting with Wscipt.shell
What result do you exactly mean? The entire dos box? or the output of the last command? And is that output always just 1 line, or not (remember that many commands produce an unknown amount of multiple lines of text output). And what exact commands do you want to use (most important question)?

As I said, it is extremely hard to do such a thing properly. Even using a simply 'trick' as commandline redirecting (which wouldn't always work depending on the command you used) where you output everything to a text file and then send the text file to the contact is troublesome and probably wont always work in a decent way.

It is very hard, if not impossible to write something generic which would always work for every command. Therefore you need to specify exactly what you want to do. "get the output" is way too general.

Believe me, it would be much much easier if you simply invoke something like remote desktop if you don't know exactly what stuff you want to do on the remote PC.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-02-2010 10:39 AM
Profile PM Find Quote Report
scripto
New Member
*


Posts: 14
30 / – / Flag
Joined: Jan 2010
O.P. RE: experimenting with Wscipt.shell
mm i just want to capture the result of the command line and all the box... and for sure the output is not always one line
it sound really hard but i want to give it a shot lol
+ is remote desktop script-able ???
04-02-2010 12:13 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: experimenting with Wscipt.shell
quote:
Originally posted by scripto
mm i just want to capture the result of the command line and all the box...
yes, but _what_ exact command line?

quote:
Originally posted by scripto
is remote desktop script-able ???
It doesn't need to be scriptable. Remote desktopping means you are in total control (at least what the other party has granted you access to) of the remote computer. You can do whatever you want as if you are physically in front of that remote computer.

This post was edited on 04-02-2010 at 01:46 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-02-2010 01:44 PM
Profile PM Find Quote Report
scripto
New Member
*


Posts: 14
30 / – / Flag
Joined: Jan 2010
O.P. RE: experimenting with Wscipt.shell
mmm let's say the "dir" command the "del"... "copy"
ipconfig
those are the basic
can we chat on msn and talk about it...
if you don't mind and after we come with a result we'll post it here so all can learn from it lol
04-02-2010 02:52 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
27 / Male / Flag
Joined: Jul 2007
RE: experimenting with Wscipt.shell
You'll need to output some stuff that is known to your script; things it'll be looking for. An example:

Batch code:
ECHO !BEGINBATCH! >> Output.txt
@ECHO OFF
ECHO !ENDCOMMAND! >> Output.txt
ipconfig /all >> Output.txt
ECHO !ENDCOMMAND! >> Output.txt
DIR C:\ >> Output.txt
ECHO !ENDCOMMAND! >> Output.txt
ECHO !ENDBATCH! >> Output.txt

Then have the script load the file and search for "!BEGINBATCH!", "!ENDCOMMAND!" and "!ENDBATCH!".

NB you'll need to know where Output.txt is located. I don't really know where you'll find it; you'll need to experiment with that.

This post was edited on 04-02-2010 at 06:46 PM by SmokingCookie.
04-02-2010 06:42 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: experimenting with Wscipt.shell
quote:
Originally posted by SmokingCookie
You'll need to output some stuff that is known to your script; things it'll be looking for. An example:

Batch code:
ECHO !BEGINBATCH! >> Output.txt
@ECHO OFF
ECHO !ENDCOMMAND! >> Output.txt
ipconfig /all >> Output.txt
ECHO !ENDCOMMAND! >> Output.txt
DIR C:\ >> Output.txt
ECHO !ENDCOMMAND! >> Output.txt
ECHO !ENDBATCH! >> Output.txt

Then have the script load the file and search for "!BEGINBATCH!", "!ENDCOMMAND!" and "!ENDBATCH!".

NB you'll need to know where Output.txt is located. I don't really know where you'll find it; you'll need to experiment with that.
Such a batch file is not needed. It is making things way too limited and too complicated.

If you take the "redirecting the command line" approach (which is already a complicated thing if you want to do it right), 'all' you need to do is to add something like "> UNIQUENAME.TXT" to the command line you've send to your remote pc.

------------------
Note that that is just a simply example, the stuff you actually need to add will be a bit more complicated as you also need to catch errors and messages which are not send to the standard output but to the secondary error stream. People who often work in DOS know what I mean; eventhough you used "> file.txt" sometimes stuff will still be printed on the screen.
eg: do "dir :: > file.txt".

So, you actually need to add "> UNIQUENAME.TXT 2>&1" to also redirect the STDERR stream to the STDOUT stream.

UNIQUENAME must be unique, as you do not want to overwrite an existing output file from a previous command which is still running.
------------------


But the hard part is that you need to wait until the command has finished before you can open the output file and send it. And if you get the command wrong, it might even be that the process will never end to begin with. Also some commands do require keyboard input (eg: "dir /p"). It speaks for its own that doing such commands (even by accident!) will render the whole process useless and the script running this will hang and probably take messenger with it.

But all in all, using this method is very limited; you can only do so much with the command line, and constantly needing to send output files doesn't work that well in practice. So, the method is a very dodgy way of doing things, because...

...If you have only a fixed set of commands you want to use, you far better use Windows APIs to do the stuff directly.

...And if you're not sure about what commands you're going to need (or want to do stuff like file and directory manipulations - you said you want to use DIR, COPY, DEL, etc), I strongly recommend using a Remote Desktop software. There are a lot of free and small Remote Desktop softwares available on the net, not to mention that it is also already available in Windows and directly accessable from Messenger. It has also the benefit that you would still be able to access your remote pc and do stuff when Messenger has problems logging in, etc. Imagine you're doing some file/dir maintenance and suddenly Messenger disconnects, then you're screwed... With remote desktopping you wont have that problem.

This post was edited on 04-03-2010 at 06:57 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
04-02-2010 11:04 PM
Profile PM Find Quote Report
Pages: (3): « First « 1 [ 2 ] 3 » Last »
« 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