Solved

Run EXE on the server from a ASP program

Posted on 2001-08-23
7
292 Views
Last Modified: 2007-12-19
Hi,
I need to compile a C program from ASP using the turbo c editor. For doing this I have to invoke the turboc exe with the filename as a parameter. I am using code something like

set wsh=Server.createobject("wscript.shell")
wsh.run("cmd /c d:\tcc -l glob.c")

NOTE: here glob.c is the file which i am trying to compile.
when i run this ASP script its not giving any error and also its not working. What might be the possible problem.
For doing this I have referred MSDN, in that I got code something like :
  Set WshShell = Wscript.CreateObject("Wscript.Shell")
  WshShell.Run ("notepad.exe")
When i try to run this script its giving run time error as
"object required at WScript.CreateObject line. So in my code I have changed WScript.createobject to server.createobject but then also its not working.
Please help me out.
0
Comment
Question by:raghu_hale
7 Comments
 
LVL 8

Expert Comment

by:drittich
ID: 6417313
0
 
LVL 5

Expert Comment

by:raizon
ID: 6417330
This isn't something that can run from serverside code.  It must be ran from client side code.  Therefore it needs to be in script tags and createobject rather than server.createobject.

<script language='VBScript'>
set wsh = CreateObject("wscript.shell")
wsh.run("cmd /c d:\tcc -l glob.c")
</script>
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6418549
You can run Wsh from the server.
BTW, what is your OS?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Accepted Solution

by:
raizon earned 50 total points
ID: 6418817
AzraSound,

I'm testing this on my localsystem running W2K Pro.

Using the code below opens up the system.ini but not the win.ini.  I have a scenario where running the wsh from the server would be helpful but have been unsuccessful thus far.


<%
Set wsh = Server.CreateObject("Wscript.Shell")
wsh.Run("notepad.exe C:\winnt\win.ini")
Set wsh = Nothing
%>
<html>
<head>
<script language="vbScript">

Set wScript = CreateObject("Wscript.Shell")
wScript.Run("notepad.exe C:\winnt\system.ini")

</script>
</head>
<body>
</body>
</html>
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6418988
Try setting the windowstyle for Notepad in the Run method.  Also, the Run method returns an error code value, so check that also to see if you are getting an error returned.  Theres a chance you are running notepad, just invisibly (might wanna check your task list).

For documentation:
http://msdn.microsoft.com/scripting/default.htm?/scripting/windowshost/doc/wsMthRun.htm
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 6418990
try aspexec from www.serverobjects.com  it's free and best way to do such things since for security and permission reasons you can't run effectively a command shell from asp..
0
 
LVL 5

Expert Comment

by:raizon
ID: 6419033
Thanks AzraSound, I didn't think of checking taskmanager, it was running invisibly.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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