Problem using Process.start to shell

B

bill

I have a VB .net 2.0 site that needs to run a dos app upon a button
click.

I found Shell too unreliable using parameters and so used
system.diagnostic.process.


simple troubleshooting example that opens up Notepad.....


Imports System.Diagnostics


Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.exe"
myProcess.StartInfo.FileName = ShellCmd

myProcess.Start()



The code works fine - but only in debug mode - ie calling the browser
from the IDE (VS Web Dev express).
When I just use a browser - any browser, I get: an error .

Access is denied
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)

When i set this up identically on my home machine it fails silently -
but still works from the IDE

Any ideas why this simple code would fail from a browser but run in
the IDE in debug mode?


Thanks

Bill
 
K

Ken Cox [Microsoft MVP]

Hi Bill,

I suspect that "Access is denied" means that the regular (non-debug) ASP.NET
account doesn't have sufficient permissions to execute that command.

When you're debugging in the IDE, I'd bet that you have privileges well
beyond those of mortal men. <grin>

I'm curious about one thing... if you do get Notepad to run outside the
environment, who is going to type the text and click Save? <grin>

Ken
 
B

bill

I did set permissions on the real command that I was trying to shell
( properties , security) - I added "Everyone" with full control and it
made no difference.


Is there another way to set permissions that I missed?

Bill
 
K

Ken Cox [Microsoft MVP]

Hi Bill,

You'll want to use impersonation in the web.config file. You need to
impersonate a Windows account that has the same rights as you do and that
can interact with the desktop.

<system.web>
<identity impersonate="true" userName="WindowsDomain\YourUserName"
password="YourPassword" />
</system.web>

Here's an article on doing the same programmatically:

http://west-wind.com/weblog/posts/1572.aspx

Ken
Microsoft MVP [ASP.NET]
 
A

a

Impersonation did not help.

Could this be some basic .Net or IIS security setting wrong on my part?

I have seen lots of seemingly easy to use examples of using Process.start on
the web so I don't understand why it should be so hard for me to start
notepad!

Bill


Ken Cox said:
Hi Bill,

You'll want to use impersonation in the web.config file. You need to
impersonate a Windows account that has the same rights as you do and that
can interact with the desktop.

<system.web>
<identity impersonate="true" userName="WindowsDomain\YourUserName"
password="YourPassword" />
</system.web>

Here's an article on doing the same programmatically:

http://west-wind.com/weblog/posts/1572.aspx

Ken
Microsoft MVP [ASP.NET]


I did set permissions on the real command that I was trying to shell
( properties , security) - I added "Everyone" with full control and it
made no difference.


Is there another way to set permissions that I missed?

Bill
 
K

Ken Cox [Microsoft MVP]

Notepad is going to be rough to start because it presents a graphical
interface in a non-graphical environment.

a said:
Impersonation did not help.

Could this be some basic .Net or IIS security setting wrong on my part?

I have seen lots of seemingly easy to use examples of using Process.start
on the web so I don't understand why it should be so hard for me to start
notepad!

Bill


Ken Cox said:
Hi Bill,

You'll want to use impersonation in the web.config file. You need to
impersonate a Windows account that has the same rights as you do and that
can interact with the desktop.

<system.web>
<identity impersonate="true" userName="WindowsDomain\YourUserName"
password="YourPassword" />
</system.web>

Here's an article on doing the same programmatically:

http://west-wind.com/weblog/posts/1572.aspx

Ken
Microsoft MVP [ASP.NET]


I did set permissions on the real command that I was trying to shell
( properties , security) - I added "Everyone" with full control and it
made no difference.


Is there another way to set permissions that I missed?

Bill




On Wed, 26 Jul 2006 22:31:38 -0400, "Ken Cox [Microsoft MVP]"

Hi Bill,

I suspect that "Access is denied" means that the regular (non-debug)
ASP.NET
account doesn't have sufficient permissions to execute that command.

When you're debugging in the IDE, I'd bet that you have privileges well
beyond those of mortal men. <grin>

I'm curious about one thing... if you do get Notepad to run outside the
environment, who is going to type the text and click Save? <grin>

Ken

I have a VB .net 2.0 site that needs to run a dos app upon a button
click.

I found Shell too unreliable using parameters and so used
system.diagnostic.process.


simple troubleshooting example that opens up Notepad.....


Imports System.Diagnostics


Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.exe"
myProcess.StartInfo.FileName = ShellCmd

myProcess.Start()



The code works fine - but only in debug mode - ie calling the browser
from the IDE (VS Web Dev express).
When I just use a browser - any browser, I get: an error .

Access is denied
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)

When i set this up identically on my home machine it fails silently -
but still works from the IDE

Any ideas why this simple code would fail from a browser but run in
the IDE in debug mode?


Thanks

Bill
 
A

a

ok but then it will better simulate my reall app I am trying to shell.

Trust me - I would would not waste so much energy trying to run Notepad :)

If "Shell" can do it easily why can't Process.start?

Should I move this thread to the security group?

Bill

Ken Cox said:
Notepad is going to be rough to start because it presents a graphical
interface in a non-graphical environment.

a said:
Impersonation did not help.

Could this be some basic .Net or IIS security setting wrong on my part?

I have seen lots of seemingly easy to use examples of using Process.start
on the web so I don't understand why it should be so hard for me to start
notepad!

Bill


Ken Cox said:
Hi Bill,

You'll want to use impersonation in the web.config file. You need to
impersonate a Windows account that has the same rights as you do and
that can interact with the desktop.

<system.web>
<identity impersonate="true" userName="WindowsDomain\YourUserName"
password="YourPassword" />
</system.web>

Here's an article on doing the same programmatically:

http://west-wind.com/weblog/posts/1572.aspx

Ken
Microsoft MVP [ASP.NET]


I did set permissions on the real command that I was trying to shell
( properties , security) - I added "Everyone" with full control and it
made no difference.


Is there another way to set permissions that I missed?

Bill




On Wed, 26 Jul 2006 22:31:38 -0400, "Ken Cox [Microsoft MVP]"

Hi Bill,

I suspect that "Access is denied" means that the regular (non-debug)
ASP.NET
account doesn't have sufficient permissions to execute that command.

When you're debugging in the IDE, I'd bet that you have privileges well
beyond those of mortal men. <grin>

I'm curious about one thing... if you do get Notepad to run outside the
environment, who is going to type the text and click Save? <grin>

Ken

I have a VB .net 2.0 site that needs to run a dos app upon a button
click.

I found Shell too unreliable using parameters and so used
system.diagnostic.process.


simple troubleshooting example that opens up Notepad.....


Imports System.Diagnostics


Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.exe"
myProcess.StartInfo.FileName = ShellCmd

myProcess.Start()



The code works fine - but only in debug mode - ie calling the browser
from the IDE (VS Web Dev express).
When I just use a browser - any browser, I get: an error .

Access is denied
at
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)

When i set this up identically on my home machine it fails silently -
but still works from the IDE

Any ideas why this simple code would fail from a browser but run in
the IDE in debug mode?


Thanks

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top