• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 68632
  • Last Modified:

Execute command window within asp

Need help using cmd to execute and display an application. I have tried Aspexec, but apparently in windows 2k sp5 it does not work, I can see the processes running in the background but can never get the actual application to display. I have allowed full access and made sure my services are enabled to interact with desktop. I've tried using Dynuexec but still know pop up of the actual application, at this point I'm just playing with a simple app like notepad. exe. What my application does is (and works) is takes a file then:
<%
Set oWSH= Server.CreateObject("WScript.Shell")

oWSH.Run "c:\winnt\lame.exe -b 16 -m m c:\inetpub\wwwroot\wavfiles\song.wav c:\inetpub\wwwroot\mp3files\song.mp3", 1, True

set oWSH = nothing
%>
The above script works great but does not show me the cmd window running the conversion. I see the process running in task manager.

Some other scripts I have tried

ASPEXEC
<%
  Set Executor = Server.CreateObject("ASPExec.Execute")
  Executor.Application = "notepad.exe"
  Executor.Parameters = "c:\autoexec.bat"
  Executor.ShowWindow = True
  Response.Write "Attempting to execute " & Executor.Application & "<br>"
  strResult = Executor.ExecuteWinApp
  Response.Write "The result of this call was: " & strResult
%>
did not open the window even after changing my setting in the services and using the internet guest acount with full access. I've tried changing the levels of security but nothing.

I've also tried:
DYNU
<%
  Set oExec = Server.CreateObject("Dynu.Exec")

  Response.Write(oExec.execute("ipconfig"))
  oExec.execute("notepad.exe")
  Response.Write(oExec.execute("nslookup -type=mx microsfot.com"))

  Set oExec = nothing
%>
Nothing
I want to execute the cmd window and watch the executable run the conversion of my files. Any help would really be appreciated as I have been working on this since very early this morning. I'm running win2k sp5 and this is going to be client side with personal web server set up etc..
1
swtlbee
Asked:
swtlbee
2 Solutions
 
mistyraeCommented:
Hi,

The reason that you cannot see the executable running is because it is being launched by another user account. In this case, the IWAM. I tested a few methods of setting security levels and modifying the application package in COM+ to use the current user in order to see the executable as it is launched, but was unsuccessful.

If you really want to see the script running, your best be is to not run the script through an ASP page, but instead create a VBS or WSH file that you execute to perform the task. Since it is being launched from the desktop, you will then be able to see the external program running.

On another note, if the external program provides status messages along the way by way of updating the cmd window with output, you can read that information into your ASP page using not the Run method of the Shell object, but the Exec method and then access the StdOut properties... This is accessible if you have 5.5+ of Cscript installed on your machine (available from http://microsoft.com/scripting)

Here is an example using the Exe method:

Set oShell = Server.CreateObject("WScript.Shell")
Set oExec = oShell.Exec(sExecStr)
Do
      tmpStr = oExec.StdOut.ReadAll()
Loop While Not oExec.Stdout.atEndOfStream
RetCode = oExec.stderr.readall

Here is some additional documentation on these methods:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wslrfscriptexecobject.asp

Hope that this was able to help you!

- misty

0
 
Mike_MetroCommented:
Since it's only going to be used locally, you can use client side vbscript to perform the task.

<SCRIPT language="VBScript">
Set oWSH= CreateObject("WScript.Shell")

oWSH.Run "c:\winnt\lame.exe -b 16 -m m c:\inetpub\wwwroot\wavfiles\song.wav c:\inetpub\wwwroot\mp3files\song.mp3", 1, True

set oWSH = nothing
</SCRIPT>

If you are using asp to populate the song names dynamically you can still do this by dynamically creating client side script, like this.

<SCRIPT language="VBScript">
Set oWSH= CreateObject("WScript.Shell")

oWSH.Run "c:\winnt\lame.exe -b 16 -m m c:\inetpub\wwwroot\wavfiles\<%=strSongName%>.wav c:\inetpub\wwwroot\mp3files\<%=strSongName%>.mp3", 1, True

set oWSH = nothing
</SCRIPT>


0
 
swtlbeeAuthor Commented:
How do I prevent the file download windo from coming up when I execute the script in the browser.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Mike_MetroCommented:
How are you calling the function.  Through a button, a hyperlink, or ?
0
 
mistyraeCommented:
Hi,

Mike_Metro's answer is absolutely correct. As long as you are using IE, you can use the client-side VBScript to call the exe and view the output on the desktop.

Here is an example that will launch notepad.exe using a form button or a hyperlink.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Pop Exe </TITLE>

<SCRIPT language="VBScript" type="text/vbscript">

Function PopExe
      Dim oWSH

      Set oWSH= CreateObject("WScript.Shell")

      oWSH.Run "notepad.exe", 1, True

      set oWSH = nothing

End Function

</SCRIPT>

</HEAD>

<BODY>

<form>
      <input type="button" name="btnLaunch" onClick="PopExe" value="Launch Exe">
</form>

<a href="#" onClick="PopExe">Launch Exe</a>

</BODY>
</HTML>


- misty
0
 
RickDaiCommented:
Is Wscript available on all windows platforms?
0
 
rizguy79Commented:
dear mistyrae
i am really very dipressed as i am unable to do the same task that is invoking an vb exe from client to pass one parameter...
i tried this code but the prob. is that it only runs process does not show any interface at server side...
can u please help me out otherwise i will mad..............
0
 
ChcukGroschenCommented:
The problem I am having is this:
dim wsh
set wsh = CreateObject("wscript.shell")
wsh.run ("D:\....\prog.exe")
set wsh = nothing

This works fine on W2K professional and W2K Server.  I am unable to create the shell activeX object on XP Pro Service Pack 1.  I know all objects are registered becasue this same code executes just fine from a VB program or from vbs.  I just get the failure on an ASP page.
0
 
MohamadiCommented:
first of all Thanks for the answer but non of above dose not work,
 error: "object expected"

it does not know the shell object
what shall I do?
0
 
David_ArthurCommented:
CHcukGroschen,

Does your anti-virus program has Script Blocking enabled?  Just a guess.
0
 
ramasamy_ramsCommented:
dear's

i am really very dipressed as i am unable to do the same task .
I want to call an exe from client machine...
 The following code is well calling an exe file from server not from client machine...

        Dim WshShell
        WshShell = CreateObject("WScript.Shell")
        WshShell.Run("C:\temp\exeupload.exe")
        WshShell = Nothing



i tried this code but the prob. is that it only runs process  does not show any interface at server side and what i expect is i need to run from client machine not from server...
can u please help me out ..............

thanks in advance...
if had some coding can u pls send it to

ramasamy.p@gmail.com

Rams
0
 
unosmsCommented:
i executed this script

<%
Dim oScheduler
Dim objTask
Dim objTrigger
Set oScheduler = CreateObject("Scheduler.SchedulingAgent.1")
Dim TaskName

Set objTask = oScheduler.Tasks.Add("CheckRegistrationReminder")
TaskName = "C:\WINNT\system32\wscript.exe """ & "C:\Program Files\NellieAdmin\" & "CheckRegistrationReminder.vbs """
objTask.ApplicationName = TaskName
objTask.Comment = "blah blah some comment"
objTask.Creator = "Script File"
objTask.WorkingDirectory = "C:\WINNT\system32"
%>

the error said

Microsoft VBScript runtime  error '800a01ad'

ActiveX component can't create object: 'Scheduler.SchedulingAgent.1'

/schedtask.asp, line 5

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now