Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

WScript Object - Example needed

[I accidentally posted this question under "web development" but I don't know how to delete it - needless to say I got no answer there and wasted points]

I know how to write the codes but it doesn't work for me.  I mean thing was done after running the asp file.

Here is the ASP code:
'=========================
<%
dim WshShell
set wshshell=server.CreateObject("WScript.shell")
WshShell.Run("c:\test.bat")
Set WshShell=Nothing
%>
'==========================
Here is the content of test.bat:

echo this is a test>test.log

After running the above asp code I expect to see a file test.log in my c:\ directory on the server.  But I don't see it.  Can someone give me an example of a working code so I can test to see this shell command object actually works ?

Thanks in advance.  If it works I'll increase the points of course.
0
keystrokes
Asked:
keystrokes
  • 7
  • 5
  • 4
  • +1
1 Solution
 
ejulsonCommented:
The Wscript.Shell object is not available to IIS.This object is only available to the Windows Scripting Host.

If you want to write to a file, you should consider using a FileSystemObject in your ASP page.
0
 
ejulsonCommented:
The Wscript.Shell object is not available to IIS.This object is only available to the Windows Scripting Host.

If you want to write to a file, you should consider using a FileSystemObject in your ASP page.
0
 
keystrokesAuthor Commented:
Do you have any links, references?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
keystrokesAuthor Commented:
I found a link from microsoft that this object works. http://support.microsoft.com/default.aspx?scid=kb;en-us;301309#5
0
 
keystrokesAuthor Commented:
This crap only works on some servers.  I have heard some report from some people the exact same code worked.  Anyone knows why?
0
 
mikkolsoftCommented:
keystrokes:

That code runs provided that you have Visual Studio 6.0 (or up I assume).

"This method requires that you install Visual Basic 6.0. In this method, you create a Visual Basic ActiveX DLL project in order to create a COM component that you can use in your ASP page. This COM component contains a method that uses the LogEvent method of the Application object to write the passed text to the Event Log."

Whereas FSO is always available.
Look at the example here: http://asp-hispeed-logging.pstruh.cz/help/ScptUtl/pa24.htm

Mikkol
0
 
ejulsonCommented:
It is the process permissions that IIS 5 is running under.  I'm looking for a doc to explain this, but if you change the "Application Protection" on the website to "Low", your problem should be solved.  (With noted security issues!)
0
 
ejulsonCommented:
Application Protection

Select whether applications are run in the same process as Web services (low), in an isolated pooled process in which other applications are also run (medium), or in an isolated process separate from other processes (high).

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/htm/developingdebuggingandsecuringiisapplications.asp


0
 
mgfranzCommented:
"The Wscript.Shell object is not available to IIS.This object is only available to the Windows Scripting Host."???

What is this?

Your code is fine, the problem has to do with permissions that the file and the directory you are trying to run the WScript from, the IUSER_ has to have Read/Write/Exe perms on the directory or the file.
0
 
mgfranzCommented:
More details here; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsoriWindowsScriptHost.asp

And:
* Run the Internet Services Manager for IIS.
* Right Click on the Website in question and select properties
* Under the 'Directory' Tab, Towards the bottom, change Execute Permissions from Scripts Only to Scripts and Executables.

0
 
mgfranzCommented:
You don't need Visual Basic either, WSH is installed with XP and W2K, but if you are not sure it's installed you can get it here; http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/728/msdncompositedoc.xml
0
 
mgfranzCommented:
And one other thing, if you are running Norton Anti-Virus, the original wshost.ocx is over-wrote by Norton.  You will have to unregister the .ocx, then re-register the original .ocx

This is an awful lot of help for 20 points...
0
 
keystrokesAuthor Commented:
mikkolsoft:

Where did you get the quote from?  Please send me the link.  This sounds odd: I actually tried to LogEvent method and it worked.  But the Run function didn't work.  If it was a VB component problem, wouldn't it affect the LogEvent method also?
0
 
keystrokesAuthor Commented:
mqfranz:
You know I am very generous with the points.  I give 20 points to the answer that sounds technically correct regardless of the issue, eventhough it doesn't solve my problem.  If it does, the points will increased accordingly.
0
 
mgfranzCommented:
Did you try my suggestion of unregistering the .ocx and .dll, then reinstalling WSH?

There are a lot of good suggestions here, (some better than others), have you had a chance to try them out?

If you ask CS to delete the Q at WD I'm sure they will accomidate you.
0
 
mikkolsoftCommented:
keystrokes:

haha I found that from the MS link you provided! Just a bit under it which says "Requirements That Are Specific to This Method" :P Good luck.

Mikkol
0
 
keystrokesAuthor Commented:
mikkolsoft:

I don't doubt that this component is required for specific IIS settings, otherwise I'd have made it work already, with mqfranz's so many suggestions.
0
 
keystrokesAuthor Commented:
Guess what guys?

The component was working all this time but I just didn't know it because it took me for a detour.  I did a file search and I found the product of the asp using wsh.  It's actually under two directries, one is the "winnt\system32" and the other one is under "documents and settings\user1\recent", instead of the root directory where the batch file is located.  

As for running any other files such as exe files, I guess I'll have to change the setting of the server to see if it works.  For the time being, this is fine for my purpose.  

Hope this will help your future development!  Hey you guys got to give me the points instead.  

Actually, I'll give mqfranz the points for his hard work, and thanks everyone.
0
 
mikkolsoftCommented:
Glad to know it works. Yes mqfranz deserves the pts for the research and stuff :)

Mikkol
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 7
  • 5
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now