Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run an .exe file using ASP code 1

Status
Not open for further replies.

Gragi

Programmer
Oct 4, 2004
59
US
Hi,
I am trying to search for some DLLs at the local system, if those DLLs are not available then
it should execute the .EXE file which is in the server. I was able to do till searching DLLs, but
afterwards how to make that executable run.

I am expecting something like, when you try to open some webpages it asks to install ActiveXControls
and displays a windows and with Run button. So Iam expecting that kind of output. Even if it is not that
fancy, if it is just able to display it's installing that EXE file is also fine for me.

Thank You Very much,
Gragi
 
if those DLLs are not available then
it should execute the .EXE file which is in the server.

Do you want the .EXE to run on the server or are you saying that a copy of the .EXE should be downloaded from the server and executed on the browser client machine?
 
If you want it to run on the local machine maybe an .MSI type script is more appropriate... the browser might give a nasty security message when you try to execute badspyware.exe
 
Thanks for you response....
I have .EXE file on the server,
I have written some code like this
For i = 0 to 7
curFile = CurPath1 & dlls(i)
IF fso.FileExists(curFile) = TRUE THEN
Flag = "TRUE"
ELSE
Flag = "FALSE"
End If
NEXT

IF FLAG = "FALSE" THEN
----> Execute the .EXE
End If

In the above code if the FLAG is FALSE then make the .EXE file run. I need code to execute the .EXE and display a message like installing .EXE.

Thank You,
Gargi

 
Right but does your EXE run on the server or the client?
 
If Crystal Reports is not found in the client system, then this viewer will be installed to view the reports. It's npviewer.exe which is to display Crystal Report from ASP.

Thanks,
Gragi
 
I want this .EXE run on the client...
 
ASP is server-side. When you run your FSO loop from an ASP page to check for the presence of the DLLs it's going to check on the server. You might be able to do this in client-side VBScript or Javascript, but it will need to be client-side and it will have to be from IE so you can use ActiveX objects (like FileSystemObject).

barcode_1.gif
 
I got it, now I changed my code to VBScript so it runs at client system. Now it is searching for the DLLs at the client location and displaying whether found or not.
But how to write the code to execute the .EXE file in the server to run at client system.

Thank You,
Gragi
 
Download it to the client machine and then execute it.
 
Unless it is on an intranet where the users could do something like map to a share on the web server.
 
It's in the intranet web,
I don't know how to write the code to download or execute from VBScript.

I really appreciate your responses.

Thank You,
Gragi
 
Howdy Gragi,

I have written code in ASP that calls and runs an .exe file that is on a server.

I registered a free DLL called ASPExec on our server and called that to run the exe file I am using. I can't remember where I got ASPExec from, but searching google will find it for sure.

Hope this helps.

Code:
    Set Executor = Server.CreateObject("ASPExec.Execute")
    Executor.Application = "D:\Visual CUT\Visual CUT.exe"
	
    Executor.Parameters = strString
    Executor.ShowWindow = False
    Executor.TimeOut = 12000
    strResult = Executor.ExecuteWinApp
 
But Gragi wants to run the program on the browser machine instead of the server machine.

Assuming the intranet users can reach a public share on your web server... and assuming internet explorer... you could do something like:

Set MyShell = CreateObject("WScript.Shell")
MyShell.Run "\\RemoteServer\PublicSharedFolder\Notepad.exe
 
Do you mean ASPExec.dll? I just downloaded this from the following website.


Then I registered the dll, but it's not running any executable.

So then I tried with the following code

Set WshShell = Wscript.CreateObject ("Wscript.Shell")
WshShell.Run "path/executablefile", 1, false

then it is working, but it's displaying OPEN/SAVE/Cancel window twice. Is there any way that we can avoid this?

Thank You,
Gragi
 
I am not sure what you mean when you said "but it's not running any executable"?
On the website link you provided, they state that "AspExec allows you to execute DOS and Windows apps."
It is working for me.

Did you want to post the code that you tried?
 
I tried the same code you have mentioned, but only difference is for sample try I tried to exectue calc.exe(calculator) and I copied calc.exe file into my directory Begin. So then after I run the file it supposed to open the calculator right? but it's neither giving me an error or showing up anything.


Set Executor = Server.CreateObject("ASPExec.Execute")

Executor.Application = "Executor.Parameters = strString
Executor.ShowWindow = False
Executor.TimeOut = 12000
strResult = Executor.ExecuteWinApp


Thank You,
Gragi
 
one more thing as I am using VBScript
I took out Server from the line Set Executor and put like

Set Executor = CreateObject("ASPExec.Execute")
 
ASPExec.Execute is not the appropriate tool for this job... it is for running things on the server... in the context of the server machine's OS.

Think about it this way...

Two computers are connected over a network... lets call them Ann and Bob.

Both computers have the other's C:\Windows fokder mapped as a network drive to P:\

So the P:\ drive on Ann has the UNC name of \\Bob\Windows

and the P:\ drive on Bob has the UNC name of \\Ann\Windows

Both computers have their own copy of calc.exe in the folder C:\Windows\System32

The local copy of calculator is C:\Windows\System32\calc.exe

The remote copy of calculator is P:\Windows\System32\calc.exe

.

.

Now, suppose I am logged into the computer named Ann ... If I run either the version of Calc from my C:\ drive or P:\ drive it will run on the CPU of Ann. It will run under the security context of the account to which I am logged into Ann. Even though the version of calc on Ann's P:\ drive version is really on the Bob computer, the program will not execute on Bob's CPU. The program will not execute under the security of the account currently logged into Bob. In fact, there could be nobody logged into Bob.

OK, now suppose instead of a P:\ drive that Ann is connecting to Bob over a web server. The purpose of ASPExec.Execute is to allow Ann to actually cause a program to execute on the CPU of Bob, in the security context of the account being used to to run ASP pages on Bob.

While this is certainly a nifty thing to be able to do, it is not what you have described as the situation.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top