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

x
?
Solved

Execute command window within asp

Posted on 2003-10-21
12
Medium Priority
?
68,577 Views
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

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
Comment
Question by:swtlbee
[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
12 Comments
 
LVL 4

Expert Comment

by:mistyrae
ID: 9594924
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
 
LVL 6

Assisted Solution

by:Mike_Metro
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
</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
 

Author Comment

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

Expert Comment

by:Mike_Metro
ID: 9599610
How are you calling the function.  Through a button, a hyperlink, or ?
0
 
LVL 4

Accepted Solution

by:
mistyrae earned 1000 total points
ID: 9599786
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
 
LVL 2

Expert Comment

by:RickDai
ID: 10883375
Is Wscript available on all windows platforms?
0
 

Expert Comment

by:rizguy79
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..............
0
 

Expert Comment

by:ChcukGroschen
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.
0
 

Expert Comment

by:Mohamadi
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?
0
 

Expert Comment

by:David_Arthur
ID: 14671179
CHcukGroschen,

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

Expert Comment

by:ramasamy_rams
ID: 14879589
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
 

Expert Comment

by:unosms
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

0

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