Solved

Run EXE on the server from a ASP program

Posted on 2001-08-23
7
289 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now