Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activex can't create object WSHshell

Status
Not open for further replies.

blade929

IS-IT--Management
Aug 3, 2010
3
FR
Hi I'm trying to run a batch file that sits on my webserver (to run locally)
I get the following message Activex can't create object "WSHshell"

the code that I'm using is

<html>
<head>
<script language="VBScript">

Sub RunProgram
dim ws
Set Ws = CreateObject("Wscript.Shell")
Ws.Run chr(34) & "C:\inetpub\test.bat" & Chr(34), 0
Set Ws = Nothing
End Sub

</script>
</head>

<body>
<button onclick="RunProgram">Run Program</button> <p>
</body>
</html>

This ran on my local pc but gets the error from the server

Can anybody help pls

Chris
 
Tried again

this time with this script

<HTML>
<HEAD>
<TITLE>Script 4.14 - A form button example</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!-- Start hiding VBScript statements
Function myButton_onClick()

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "schtasks /run /s serverip /tn pptfix"
Set Wshshell = Nothing


msgbox("PPT fix completed")
End Function
' End hiding VBScript statements -->
</SCRIPT>
</HEAD>
<BODY>
<H3>Testing vb scripts</H3><P>
<FORM>
<INPUT NAME="myButton" TYPE="button" VALUE="Click Here">
</FORM>
</BODY>
</HTML>


The object of the script is to start a local batch file,
the batch file will then kill a process and delete files.


When I save the script as a hta it works!!

But doesn't work when saved as a html page

Any Ideas?
 
Any Ideas?
Yes: Security issue
So, keep using HTA.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I need to incorporate this into an intranet help page

Is there anyway execute this from a normal webpage?

Regards

Chris
 
If the page is called upon in anonymus (null) session, make the account iusr_<computername> having read & execute permission (write denied) of wscript.exe. And then set the read & execute and list contents permissions all along its path (such as system32, windows or winnt) Also set the same read & execute permission to whatever executable it is calling along, plus write permission to the folder where output is to go into etc. See, it looks frightening, but the starting point is the above. Once, it is successfully executed, inspect the effective permissions for all component along the chain of call to see if you need to tighten/clean up residue permissions you actually do not want them to have.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top