I was wondering if its possible to have javascript stop a service on my machine for instance terminal services and then start it again...Any help provided will be greatly appreciated
Javascript cannot do anything to the system, like starting/killing/affecting processes
or creating/editing/deleting files.
It can only read the files, if and only if: the script is run from a local file.
Well, actually it *COULD* do it on Windows, using MSIE. If you created (or found) an ActiveX control and installed it to your browser and allowed it to do "unsafe scripting" and didn't mind having to answer "yes, I know this is a bad thing to do" every time you ran the page. <grin/>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
The javascript will be ran from within an already built application...I just need the JS code for stopping a service...would either of these codes be enough to get the job done:
The second of those would work in ASP (if it works at all, that is), *NOT* in the browser. That's what runat="server" means.
The first of those *could* also be run using ASP, if you used the same runat="server". I dunno if it will work from the browser. Never tried using Wscript.Shell from the browser. But clearly the "new ActiveXObject( )" syntax is the way to use ActiveX in the browser.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
One problem you have is that if you do use ASP, the code will run as the IUSR_xxxx user (where "xxxx" is the name of the computer). That's the user that IIS runs as. So you'd have to give that user permission to do the NET commands.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Oh, and yes JS in MSIE can write local files. Again, you have to permit it to every time you run the page. But it can.
Internet Explorer lets you write to the Windows file system by means of the harmless execCommand() function. But reading from a file requires ActiveX which is not recommended for several reasons.