Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
scripts
hosting
jscript
remote
scripting.wsh
scriptlets
vbscript
virus.discussion
  
 
date: Thu, 26 Jun 2008 12:02:13 -0700 (PDT),    group: microsoft.public.scripting.wsh        back       


execute WSH in a js file from html?   
Hi all,

How can I execute a WSH program from html file? The wsh program is
stored in a .js file. I tried to include the .js file as usual:
<script type="text/javascript" src="XYZ.js">
</script>

But it didn't work.
The wsh itself works just fine when I double click on it.
Could you help me out?
date: Thu, 26 Jun 2008 12:02:13 -0700 (PDT)   author:   Luting

Re: execute WSH in a js file from html?   
"Luting"  wrote in message 
news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...
> Hi all,
>
> How can I execute a WSH program from html file? The wsh program is
> stored in a .js file. I tried to include the .js file as usual:
> <script type="text/javascript" src="XYZ.js">
> </script>
>
> But it didn't work.
> The wsh itself works just fine when I double click on it.
> Could you help me out?

The script tag you have shown will probably cause the content of the .js 
file to be made part of the script of the page. But simply including it does 
not cause it to run. For that you need to have some event fire the script, 
or have some other script that is executed call a subroutine defined within 
the .js file.

/Al
date: Thu, 26 Jun 2008 18:16:49 -0600   author:   Al Dunbar aam

Re: execute WSH in a js file from html?   
"Al Dunbar" <AlanDrub@hotmail.com.nospaam> wrote in message 
news:#AH$Wx#1IHA.3968@TK2MSFTNGP04.phx.gbl...
>
> "Luting"  wrote in message 
> news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...
>> Hi all,
>>
>> How can I execute a WSH program from html file? The wsh program is
>> stored in a .js file. I tried to include the .js file as usual:
>> <script type="text/javascript" src="XYZ.js">
>> </script>
>>
>> But it didn't work.
>> The wsh itself works just fine when I double click on it.
>> Could you help me out?
>
> The script tag you have shown will probably cause the content of the .js 
> file to be made part of the script of the page. But simply including it 
> does not cause it to run. For that you need to have some event fire the 
> script, or have some other script that is executed call a subroutine 
> defined within the .js file.
>
> /Al
>
>
You can use the WScript.Shell's Run method to call CScript/WScript.
This would need very low security level on the browser but would allow files 
that use the WScript.Sleep methods and the like to run.
If the files only contain stuff that could run in a browser environment 
anyway you can include the file as you did and just call any functions 
one-by-one.

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
date: Fri, 27 Jun 2008 08:24:21 +0100   author:   Joe Fawcett am

Re: execute WSH in a js file from html?   
On Jun 27, 12:24 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
wrote:
> "Al Dunbar" <AlanD...@hotmail.com.nospaam> wrote in message
>
> news:#AH$Wx#1IHA.3968@TK2MSFTNGP04.phx.gbl...
>
>
>
>
>
> > "Luting"  wrote in message
> >news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...> >> Hi all,
>
> >> How can I execute a WSH program from html file? The wsh program is
> >> stored in a .js file. I tried to include the .js file as usual:
> >> <script type="text/javascript" src="XYZ.js">
> >> </script>
>
> >> But it didn't work.
> >> The wsh itself works just fine when I double click on it.
> >> Could you help me out?
>
> > The script tag you have shown will probably cause the content of the .js> > file to be made part of the script of the page. But simply including it
> > does not cause it to run. For that you need to have some event fire the
> > script, or have some other script that is executed call a subroutine
> > defined within the .js file.
>
> > /Al
>
> You can use the WScript.Shell's Run method to call CScript/WScript.
> This would need very low security level on the browser but would allow files
> that use the WScript.Sleep methods and the like to run.
> If the files only contain stuff that could run in a browser environment
> anyway you can include the file as you did and just call any functions
> one-by-one.
>
> --
>
> Joe Fawcett (MVP - XML)http://joe.fawcett.name- Hide quoted text -
>
> - Show quoted text -

Hi,

I include the file and run the function I need. But it gave me an
error said "WScript is undefined."

I also tried this:
var oShell=WScript.CreateObject("WScript.shell");
oshell.Run(oApp,1,true);
oApp is the application I defined in the .js file.
This time I didn't get an error but the file was not executed at all.

How can I fix this?
Luting
date: Mon, 30 Jun 2008 07:31:07 -0700 (PDT)   author:   Luting

Re: execute WSH in a js file from html?   
On Jun 30, 10:31 am, Luting  wrote:
> On Jun 27, 12:24 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
> wrote:
>
>
>
> > "Al Dunbar" <AlanD...@hotmail.com.nospaam> wrote in message
>
> >news:#AH$Wx#1IHA.3968@TK2MSFTNGP04.phx.gbl...
>
> > > "Luting"  wrote in message
> > >news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...
> > >> Hi all,
>
> > >> How can I execute a WSH program from html file? The wsh program is
> > >> stored in a .js file. I tried to include the .js file as usual:
> > >> <script type="text/javascript" src="XYZ.js">
> > >> </script>
>
> > >> But it didn't work.
> > >> The wsh itself works just fine when I double click on it.
> > >> Could you help me out?
>
> > > The script tag you have shown will probably cause the content of the .js
> > > file to be made part of the script of the page. But simply including it
> > > does not cause it to run. For that you need to have some event fire the
> > > script, or have some other script that is executed call a subroutine
> > > defined within the .js file.
>
> > > /Al
>
> > You can use the WScript.Shell's Run method to call CScript/WScript.
> > This would need very low security level on the browser but would allow files
> > that use the WScript.Sleep methods and the like to run.
> > If the files only contain stuff that could run in a browser environment
> > anyway you can include the file as you did and just call any functions
> > one-by-one.
>
> > --
>
> > Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hide quoted text -
>
> > - Show quoted text -
>
> Hi,
>
> I include the file and run the function I need. But it gave me an
> error said "WScript is undefined."
>
> I also tried this:
> var oShell=WScript.CreateObject("WScript.shell");
> oshell.Run(oApp,1,true);
> oApp is the application I defined in the .js file.
> This time I didn't get an error but the file was not executed at all.
>
> How can I fix this?
> Luting

In an html as the host, wscript is not available.  That means its
CreateObject is also not available, but JS provides an alternative
function, ActiveXObject ...

var oShell=new ActiveXObject("WScript.Shell");
oshell.Run(oApp,1,true);

Note, that though the WScript object is not available other WSH
objects, like WScript.Shell, are resident in the wshom.ocx and
therefore they can be instantiated, regardless of the host.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
date: Mon, 30 Jun 2008 08:10:18 -0700 (PDT)   author:   Tom Lavedas

Re: execute WSH in a js file from html?   
On Jun 30, 8:10 am, Tom Lavedas  wrote:
> On Jun 30, 10:31 am, Luting  wrote:
>
>
>
>
>
> > On Jun 27, 12:24 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
> > wrote:
>
> > > "Al Dunbar" <AlanD...@hotmail.com.nospaam> wrote in message
>
> > >news:#AH$Wx#1IHA.3968@TK2MSFTNGP04.phx.gbl...
>
> > > > "Luting"  wrote in message
> > > >news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...
> > > >> Hi all,
>
> > > >> How can I execute a WSH program from html file? The wsh program is
> > > >> stored in a .js file. I tried to include the .js file as usual:
> > > >> <script type="text/javascript" src="XYZ.js">
> > > >> </script>
>
> > > >> But it didn't work.
> > > >> The wsh itself works just fine when I double click on it.
> > > >> Could you help me out?
>
> > > > The script tag you have shown will probably cause the content of the .js
> > > > file to be made part of the script of the page. But simply including it
> > > > does not cause it to run. For that you need to have some event fire the
> > > > script, or have some other script that is executed call a subroutine
> > > > defined within the .js file.
>
> > > > /Al
>
> > > You can use the WScript.Shell's Run method to call CScript/WScript.
> > > This would need very low security level on the browser but would allow files
> > > that use the WScript.Sleep methods and the like to run.
> > > If the files only contain stuff that could run in a browser environment
> > > anyway you can include the file as you did and just call any functions
> > > one-by-one.
>
> > > --
>
> > > Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hidequoted text -
>
> > > - Show quoted text -
>
> > Hi,
>
> > I include the file and run the function I need. But it gave me an
> > error said "WScript is undefined."
>
> > I also tried this:
> > var oShell=WScript.CreateObject("WScript.shell");
> > oshell.Run(oApp,1,true);
> > oApp is the application I defined in the .js file.
> > This time I didn't get an error but the file was not executed at all.
>
> > How can I fix this?
> > Luting
>
> In an html as the host, wscript is not available.  That means its
> CreateObject is also not available, but JS provides an alternative
> function, ActiveXObject ...
>
> var oShell=new ActiveXObject("WScript.Shell");
> oshell.Run(oApp,1,true);
>
> Note, that though the WScript object is not available other WSH
> objects, like WScript.Shell, are resident in the wshom.ocx and
> therefore they can be instantiated, regardless of the host.
>
> Tom Lavedas
> ===========http://members.cox.net/tglbatch/wsh/- Hide quoted text -
>
> - Show quoted text -

Thank you, Tom!
That helps a lot!
I changed my code into ActiveXObject() and it works fine, except that
there is always an alert window appearing when the page is loaded. Is
there any way to get rid of the alert window?

Luting
date: Mon, 30 Jun 2008 09:30:24 -0700 (PDT)   author:   Luting

Re: execute WSH in a js file from html?   
On Jun 30, 12:30 pm, Luting  wrote:
> On Jun 30, 8:10 am, Tom Lavedas  wrote:
>
>
>
> > On Jun 30, 10:31 am, Luting  wrote:
>
> > > On Jun 27, 12:24 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
> > > wrote:
>
> > > > "Al Dunbar" <AlanD...@hotmail.com.nospaam> wrote in message
>
> > > >news:#AH$Wx#1IHA.3968@TK2MSFTNGP04.phx.gbl...
>
> > > > > "Luting"  wrote in message
> > > > >news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...
> > > > >> Hi all,
>
> > > > >> How can I execute a WSH program from html file? The wsh program is
> > > > >> stored in a .js file. I tried to include the .js file as usual:
> > > > >> <script type="text/javascript" src="XYZ.js">
> > > > >> </script>
>
> > > > >> But it didn't work.
> > > > >> The wsh itself works just fine when I double click on it.
> > > > >> Could you help me out?
>
> > > > > The script tag you have shown will probably cause the content of the .js
> > > > > file to be made part of the script of the page. But simply including it
> > > > > does not cause it to run. For that you need to have some event fire the
> > > > > script, or have some other script that is executed call a subroutine
> > > > > defined within the .js file.
>
> > > > > /Al
>
> > > > You can use the WScript.Shell's Run method to call CScript/WScript.
> > > > This would need very low security level on the browser but would allow files
> > > > that use the WScript.Sleep methods and the like to run.
> > > > If the files only contain stuff that could run in a browser environment
> > > > anyway you can include the file as you did and just call any functions
> > > > one-by-one.
>
> > > > --
>
> > > > Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hidequotedtext -
>
> > > > - Show quoted text -
>
> > > Hi,
>
> > > I include the file and run the function I need. But it gave me an
> > > error said "WScript is undefined."
>
> > > I also tried this:
> > > var oShell=WScript.CreateObject("WScript.shell");
> > > oshell.Run(oApp,1,true);
> > > oApp is the application I defined in the .js file.
> > > This time I didn't get an error but the file was not executed at all.
>
> > > How can I fix this?
> > > Luting
>
> > In an html as the host, wscript is not available.  That means its
> > CreateObject is also not available, but JS provides an alternative
> > function, ActiveXObject ...
>
> > var oShell=new ActiveXObject("WScript.Shell");
> > oshell.Run(oApp,1,true);
>
> > Note, that though the WScript object is not available other WSH
> > objects, like WScript.Shell, are resident in the wshom.ocx and
> > therefore they can be instantiated, regardless of the host.
>
> > Tom Lavedas
> > ===========http://members.cox.net/tglbatch/wsh/-Hide quoted text -
>
> > - Show quoted text -
>
> Thank you, Tom!
> That helps a lot!
> I changed my code into ActiveXObject() and it works fine, except that
> there is always an alert window appearing when the page is loaded. Is
> there any way to get rid of the alert window?
>
> Luting

This is a security issue with client-side scripting.  The
Wscript.Shell object is marked as 'unsafe for scripting' - which it
most certainly is.  Therefore, the user must decide to alter their
security setting to eliminate this warning.  Fotr a detailed
discussion of the subject see:
http://groups.google.com/group/microsoft.public.scripting.vbscript/msg/2780d2ce4c1d57b4?hl=en&dmode=source

A common alternative is to convert your HTML application to a
Hypertext Application (HTA) instead.  This substantially reduces or
eliminates such security requirements.  Most HTMLs only require
changing the extension from HTML (HTM) to HTA.  However, the file then
becomes an application that must be downloaded to and run from the
user's machine.  It is no longer hosted by their browser.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
date: Mon, 30 Jun 2008 10:28:32 -0700 (PDT)   author:   Tom Lavedas

Re: execute WSH in a js file from html?   
On Jun 30, 10:28 am, Tom Lavedas  wrote:
> On Jun 30, 12:30 pm, Luting  wrote:
>
>
>
>
>
> > On Jun 30, 8:10 am, Tom Lavedas  wrote:
>
> > > On Jun 30, 10:31 am, Luting  wrote:
>
> > > > On Jun 27, 12:24 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
> > > > wrote:
>
> > > > > "Al Dunbar" <AlanD...@hotmail.com.nospaam> wrote in message
>
> > > > >news:#AH$Wx#1IHA.3968@TK2MSFTNGP04.phx.gbl...
>
> > > > > > "Luting"  wrote in message
> > > > > >news:9a076733-b29d-49ca-b814-3b3c3c2535d2@i76g2000hsf.googlegroups.com...
> > > > > >> Hi all,
>
> > > > > >> How can I execute a WSH program from html file? The wsh program is
> > > > > >> stored in a .js file. I tried to include the .js file as usual> > > > > >> <script type="text/javascript" src="XYZ.js">
> > > > > >> </script>
>
> > > > > >> But it didn't work.
> > > > > >> The wsh itself works just fine when I double click on it.
> > > > > >> Could you help me out?
>
> > > > > > The script tag you have shown will probably cause the content of the .js
> > > > > > file to be made part of the script of the page. But simply including it
> > > > > > does not cause it to run. For that you need to have some event fire the
> > > > > > script, or have some other script that is executed call a subroutine
> > > > > > defined within the .js file.
>
> > > > > > /Al
>
> > > > > You can use the WScript.Shell's Run method to call CScript/WScript.
> > > > > This would need very low security level on the browser but would allow files
> > > > > that use the WScript.Sleep methods and the like to run.
> > > > > If the files only contain stuff that could run in a browser environment
> > > > > anyway you can include the file as you did and just call any functions
> > > > > one-by-one.
>
> > > > > --
>
> > > > > Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hidequotedtext-
>
> > > > > - Show quoted text -
>
> > > > Hi,
>
> > > > I include the file and run the function I need. But it gave me an
> > > > error said "WScript is undefined."
>
> > > > I also tried this:
> > > > var oShell=WScript.CreateObject("WScript.shell");
> > > > oshell.Run(oApp,1,true);
> > > > oApp is the application I defined in the .js file.
> > > > This time I didn't get an error but the file was not executed at all.
>
> > > > How can I fix this?
> > > > Luting
>
> > > In an html as the host, wscript is not available.  That means its
> > > CreateObject is also not available, but JS provides an alternative
> > > function, ActiveXObject ...
>
> > > var oShell=new ActiveXObject("WScript.Shell");
> > > oshell.Run(oApp,1,true);
>
> > > Note, that though the WScript object is not available other WSH
> > > objects, like WScript.Shell, are resident in the wshom.ocx and
> > > therefore they can be instantiated, regardless of the host.
>
> > > Tom Lavedas
> > > ===========http://members.cox.net/tglbatch/wsh/-Hidequoted text -
>
> > > - Show quoted text -
>
> > Thank you, Tom!
> > That helps a lot!
> > I changed my code into ActiveXObject() and it works fine, except that
> > there is always an alert window appearing when the page is loaded. Is
> > there any way to get rid of the alert window?
>
> > Luting
>
> This is a security issue with client-side scripting.  The
> Wscript.Shell object is marked as 'unsafe for scripting' - which it
> most certainly is.  Therefore, the user must decide to alter their
> security setting to eliminate this warning.  Fotr a detailed
> discussion of the subject see:http://groups.google.com/group/microsoft.public.scripting.vbscript/ms...
>
> A common alternative is to convert your HTML application to a
> Hypertext Application (HTA) instead.  This substantially reduces or
> eliminates such security requirements.  Most HTMLs only require
> changing the extension from HTML (HTM) to HTA.  However, the file then
> becomes an application that must be downloaded to and run from the
> user's machine.  It is no longer hosted by their browser.
>
> Tom Lavedas
> ===========http://members.cox.net/tglbatch/wsh/- Hide quoted text -
>
> - Show quoted text -

Hi Tom,

I really appreciate it.
The HTA solution really helps.

Thanks.
date: Mon, 30 Jun 2008 12:29:08 -0700 (PDT)   author:   Luting

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us