[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Execute command window within asp

Posted on 2003-10-21
Medium Priority
1 Endorsement
Last Modified: 2012-05-04
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

  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:
  Set oExec = Server.CreateObject("Dynu.Exec")

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

  Set oExec = 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..
Question by:swtlbee
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

Expert Comment

ID: 9594924

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)
      tmpStr = oExec.StdOut.ReadAll()
Loop While Not oExec.Stdout.atEndOfStream
RetCode = oExec.stderr.readall

Here is some additional documentation on these methods:

Hope that this was able to help you!

- misty


Assisted Solution

Mike_Metro earned 1000 total points
ID: 9595377
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

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


Author Comment

ID: 9599550
How do I prevent the file download windo from coming up when I execute the script in the browser.
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!


Expert Comment

ID: 9599610
How are you calling the function.  Through a button, a hyperlink, or ?

Accepted Solution

mistyrae earned 1000 total points
ID: 9599786

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">
<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




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

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


- misty

Expert Comment

ID: 10883375
Is Wscript available on all windows platforms?

Expert Comment

ID: 10886322
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..............

Expert Comment

ID: 13014823
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.

Expert Comment

ID: 14666748
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?

Expert Comment

ID: 14671179

Does your anti-virus program has Script Blocking enabled?  Just a guess.

Expert Comment

ID: 14879589

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 = 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



Expert Comment

ID: 33460199
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


Featured Post

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.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 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