?
Solved

WScript Object - Example needed

Posted on 2003-02-27
19
Medium Priority
?
486 Views
Last Modified: 2011-09-20
[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
Comment
Question by:keystrokes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 4
  • +1
19 Comments
 

Expert Comment

by:ejulson
ID: 8036753
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
 

Expert Comment

by:ejulson
ID: 8036819
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
 
LVL 3

Author Comment

by:keystrokes
ID: 8036871
Do you have any links, references?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:keystrokes
ID: 8036939
I found a link from microsoft that this object works. http://support.microsoft.com/default.aspx?scid=kb;en-us;301309#5
0
 
LVL 3

Author Comment

by:keystrokes
ID: 8037600
This crap only works on some servers.  I have heard some report from some people the exact same code worked.  Anyone knows why?
0
 
LVL 2

Expert Comment

by:mikkolsoft
ID: 8037616
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
 

Expert Comment

by:ejulson
ID: 8037627
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
 

Expert Comment

by:ejulson
ID: 8037690
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
 
LVL 18

Expert Comment

by:mgfranz
ID: 8039136
"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
 
LVL 18

Expert Comment

by:mgfranz
ID: 8039258
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
 
LVL 18

Expert Comment

by:mgfranz
ID: 8039267
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
 
LVL 18

Accepted Solution

by:
mgfranz earned 80 total points
ID: 8039292
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
 
LVL 3

Author Comment

by:keystrokes
ID: 8042632
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
 
LVL 3

Author Comment

by:keystrokes
ID: 8042665
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
 
LVL 18

Expert Comment

by:mgfranz
ID: 8042963
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
 
LVL 2

Expert Comment

by:mikkolsoft
ID: 8043834
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
 
LVL 3

Author Comment

by:keystrokes
ID: 8043946
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
 
LVL 3

Author Comment

by:keystrokes
ID: 8044204
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
 
LVL 2

Expert Comment

by:mikkolsoft
ID: 8044417
Glad to know it works. Yes mqfranz deserves the pts for the research and stuff :)

Mikkol
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question