Shell problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is a re-post of an earlier problem which I have not been able to solve yet.
I'm running .NET 2003 on XP.
I am trying to launch a Windows program from a VB Web app.
The code I am using is;

Try
Dim psi As New System.Diagnostics.Process
psi.StartInfo.UseShellExecute = True
psi.StartInfo.WorkingDirectory = "c:\"
psi.StartInfo.FileName = "WinApp.exe"
psi.Start()
Catch
System.Diagnostics.Debug.WriteLine(Err.Number & ", " & Err.Description)
End Try
Exit Sub

The results are...
no Exception occurs
An audible chime sounds (sounds like Win * sound)
WinApp.exe appears in the Processes list of the Windows Task Manager
WinApp.exe fails to execute

I have tried the same code in .Net Windows VB and WinApp.exe executes.
There apparently is some difference in launching from a Web app that I haven't been able to figure out.

Any help would be deeply appreciated.

Thanks,
John F.
 
Hi John,

Probably a user right, the Web application is standard running as the user
ASPNET, mostly is that the problem because that one has not so much rights
(should not have).

I hope that is it as well with you?

Cor
This is a re-post of an earlier problem which I have not been able to solve yet.
I'm running .NET 2003 on XP.
I am trying to launch a Windows program from a VB Web app.
The code I am using is;

Try
Dim psi As New System.Diagnostics.Process
psi.StartInfo.UseShellExecute = True
psi.StartInfo.WorkingDirectory = "c:\"
psi.StartInfo.FileName = "WinApp.exe"
psi.Start()
Catch
System.Diagnostics.Debug.WriteLine(Err.Number & ", " & Err.Description)
End Try
Exit Sub

The results are...
no Exception occurs
An audible chime sounds (sounds like Win * sound)
WinApp.exe appears in the Processes list of the Windows Task Manager
WinApp.exe fails to execute

I have tried the same code in .Net Windows VB and WinApp.exe executes.
There apparently is some difference in launching from a Web app that I
haven't been able to figure out.
 
* =?Utf-8?B?Sm9obiBG?= said:
This is a re-post of an earlier problem which I have not been able to solve yet.
I'm running .NET 2003 on XP.
I am trying to launch a Windows program from a VB Web app.
The code I am using is;

Try
Dim psi As New System.Diagnostics.Process
psi.StartInfo.UseShellExecute = True
psi.StartInfo.WorkingDirectory = "c:\"
psi.StartInfo.FileName = "WinApp.exe"
psi.Start()
Catch
System.Diagnostics.Debug.WriteLine(Err.Number & ", " & Err.Description)
End Try
Exit Sub

The results are...
no Exception occurs
An audible chime sounds (sounds like Win * sound)
WinApp.exe appears in the Processes list of the Windows Task Manager
WinApp.exe fails to execute

Is there an entry in the event log? Did you try to impersonate a user
with more rights? I doubt that the "ASPNET" user is allowed to launch
applications that are installed on your machine.
 
Hi John,

I would never change the rights of the ASPNET user, that makes your server
almost an open server.

Try this question in the newsgroup

microsoft.public.dotnet.framework.security

Security is not something that has to be done in a language group in my
opinion.
However just my opinion.

Cor
 
Unless you have overridden most of the security rights that the ASP.NET user is set to (not just the group), then the ASP.NET user will not be able to run an application that sits in the root directory. Try moving the WinApp.exe to a directory of the web site.

HTH
 
* =?Utf-8?B?Sm9obiBG?= said:
Do you have sample code for impersonation that you could share?

I am not familiar with ASP.NET, so I currently don't have a sample, but
I know that this is a hot topic in the ASP.NET group.
 
This is a re-post of an earlier problem which I have not been able to
solve yet.
I'm running .NET 2003 on XP.
I am trying to launch a Windows program from a VB Web app.
[snippage]

The results are...
no Exception occurs
An audible chime sounds (sounds like Win * sound)
WinApp.exe appears in the Processes list of the Windows Task Manager
WinApp.exe fails to execute

I have tried the same code in .Net Windows VB and WinApp.exe executes.
There apparently is some difference in launching from a Web app that I
haven't been able to figure out.

heh. I get to write a "Dear John" letter:

I don't have empirical fact here, but I bet your WinApp.exe really is
executing.

I played (hacked, really) around with this a little bit and to me, it seems
like ASP.NET and COM+ EnterpriseServices both show the same behavior:

The launched application launches and remains in memory as if it is waiting
for a user to interact with it, but displays no UI. I don't know of a
solution, but as far as I can tell, that's what's happening. I would
recommend experimenting with calling a console application like PKZIP and
see if you can make it actually zip files, or if the process just loads and
hangs. If it actually does what it's supposed to do even without a UI, I
think you're OK.

Remember that ASP.NET has been designed so that stuff running at the server
can run without user intervention because at the web server, there is
probably not anyone looking at the screen. There is probably not anyone
even logged on at a server. So stuff that is designed to run on a server
can't have a UI.

You can also see this behavior in VB 6. If you make an ActiveX DLL in VB 6
that has a method that throws a MsgBox and compile it with the "unattended
execution" option, the MsgBox will run, but not on the screen, and you'll
see an item in the Application Event Log that describes what the MsgBox
*attempted* to display.

IMHO, you should not be launching user-interactive applications from ASP.NET
or from COM+. If you really want the user of your web application to be
able to launch this other application, try to find a way to do it
client-side, from the browser, like by using an ActiveX control that
provides the UI (remember, there's nothing stopping you from writing a WHOLE
program as an OCX, forms and all!), or by using .hta instead of .htm to be
able to run with full trust so that it can launch the other application.

A word about the ActiveX control idea: If you try this approach, be
*extremely* cautious about how you design it. If you give it a property
like "AppToLaunch" then it gets webified like this:

<object ....>
<param name="AppToLaunch" value="WinApp.exe">
</object>

Then you introduce a dangerous security threat because if I were a badguy, I
could get *your* control to run *my* app that is written to do all sorts of
horrible things.

Also, since launching one application from another *always* implies a
potential for security issues, have a chat with one of your network admins
about what you are planning to do; be warned in advance, your network admins
will sound justifiably paranoid about this. :)
 
What I use it for is to send me a message on my cell phone (in this test
case I use Outlook express) if the Web app encounters problems. Just trying
to raise the service level during the testing phase of a new Web App.

Ahhhhh......

Here's a better solution then. In the MSPress "Visual Basic .NET
Programmer's Cookbook" on page 281, there is a discussion and howto about
sending SMTP mail. at this address is a self-extracing exe that contains
the companion content and code samples. You can dig out "recipe 8.12" to
see how to do this using the .Net Framework MailMessage class.

This will wrap:

http://download.microsoft.com/download/e/d/e/ede00423-7733-4744-9cbe-90627d619e75/VBCookbook.exe
 
Clarification;

I only want to SEND a message from the server-side of a Web app, which is why I tried using the shell process in the first place.

The reference I gave you is about Reading Email messages, but I will try to use the approach to do a Send.

Didn't want to mislead you about what I'm trying to do.

Thanks again,
John F.
 
Back
Top