473,662 Members | 2,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem using Process.start to shell

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.diagnost ic.process.
simple troubleshooting example that opens up Notepad.....
Imports System.Diagnost ics
Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.ex e"
myProcess.Start Info.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.Diagnost ics.Process.Sta rtWithShellExec uteEx(ProcessSt artInfo
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
Jul 27 '06 #1
6 3214
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

<bi**@abc.comwr ote in message
news:hb******** *************** *********@4ax.c om...
>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.diagnost ic.process.
simple troubleshooting example that opens up Notepad.....
Imports System.Diagnost ics
Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.ex e"
myProcess.Start Info.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.Diagnost ics.Process.Sta rtWithShellExec uteEx(ProcessSt artInfo
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

Jul 27 '06 #2
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]"
<BA**********@n ewsgroups.nospa mwrote:
>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

<bi**@abc.comw rote in message
news:hb******* *************** **********@4ax. com...
>>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.diagnos tic.process.
simple troubleshooting example that opens up Notepad.....
Imports System.Diagnost ics
Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.ex e"
myProcess.Start Info.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.Diagnost ics.Process.Sta rtWithShellExec uteEx(ProcessSt artInfo
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
Jul 27 '06 #3
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="tr ue" userName="Windo wsDomain\YourUs erName"
password="YourP assword" />
</system.web>

Here's an article on doing the same programmaticall y:

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

Ken
Microsoft MVP [ASP.NET]
<bi**@abc.comwr ote in message
news:31******** *************** *********@4ax.c om...
>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]"
<BA**********@n ewsgroups.nospa mwrote:
>>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

<bi**@abc.com wrote in message
news:hb****** *************** ***********@4ax .com...
>>>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.diagno stic.process.
simple troubleshooting example that opens up Notepad.....
Imports System.Diagnost ics
Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.ex e"
myProcess.Start Info.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.Diagnost ics.Process.Sta rtWithShellExec uteEx(ProcessSt artInfo
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

Jul 27 '06 #4
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 [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in message
news:Oz******** ******@TK2MSFTN GP04.phx.gbl...
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="tr ue" userName="Windo wsDomain\YourUs erName"
password="YourP assword" />
</system.web>

Here's an article on doing the same programmaticall y:

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

Ken
Microsoft MVP [ASP.NET]
<bi**@abc.comwr ote in message
news:31******** *************** *********@4ax.c om...
>>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]"
<BA**********@ newsgroups.nosp amwrote:
>>>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
environmen t, who is going to type the text and click Save? <grin>

Ken

<bi**@abc.co mwrote in message
news:hb***** *************** ************@4a x.com...
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.diagn ostic.process.
simple troubleshooting example that opens up Notepad.....
Imports System.Diagnost ics
Dim myProcess As New Process
Dim ShellCmd As String

ShellCmd = "notepad.ex e"
myProcess.Start Info.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.Diagnost ics.Process.Sta rtWithShellExec uteEx(ProcessSt artInfo
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


Jul 27 '06 #5
Notepad is going to be rough to start because it presents a graphical
interface in a non-graphical environment.

"a" <aa@ss.comwro te in message
news:hR******** *********@torna do.tampabay.rr. com...
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 [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in
message news:Oz******** ******@TK2MSFTN GP04.phx.gbl...
>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="tr ue" userName="Windo wsDomain\YourUs erName"
password="Your Password" />
</system.web>

Here's an article on doing the same programmaticall y:

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

Ken
Microsoft MVP [ASP.NET]
<bi**@abc.comw rote in message
news:31******* *************** **********@4ax. com...
>>>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]"
<BA********** @newsgroups.nos pamwrote:

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

<bi**@abc.c omwrote in message
news:hb**** *************** *************@4 ax.com...
>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.diag nostic.process.
>
>
simple troubleshooting example that opens up Notepad.....
>
>
Imports System.Diagnost ics
>
>
Dim myProcess As New Process
Dim ShellCmd As String
>
ShellCmd = "notepad.ex e"
myProcess.Start Info.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.Diagnost ics.Process.Sta rtWithShellExec uteEx(ProcessSt artInfo
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




Jul 27 '06 #6
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 [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in message
news:uW******** ******@TK2MSFTN GP04.phx.gbl...
Notepad is going to be rough to start because it presents a graphical
interface in a non-graphical environment.

"a" <aa@ss.comwro te in message
news:hR******** *********@torna do.tampabay.rr. com...
>Impersonatio n 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 [Microsoft MVP]" <BA**********@n ewsgroups.nospa mwrote in
message news:Oz******** ******@TK2MSFTN GP04.phx.gbl...
>>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="tr ue" userName="Windo wsDomain\YourUs erName"
password="You rPassword" />
</system.web>

Here's an article on doing the same programmaticall y:

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

Ken
Microsoft MVP [ASP.NET]
<bi**@abc.com wrote in message
news:31****** *************** ***********@4ax .com...
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]"
<BA********* *@newsgroups.no spamwrote:

>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
>environmen t, who is going to type the text and click Save? <grin>
>
>Ken
>
><bi**@abc. comwrote in message
>news:hb*** *************** **************@ 4ax.com...
>>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.dia gnostic.process .
>>
>>
>simple troubleshooting example that opens up Notepad.....
>>
>>
>Imports System.Diagnost ics
>>
>>
> Dim myProcess As New Process
> Dim ShellCmd As String
>>
> ShellCmd = "notepad.ex e"
> myProcess.Start Info.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.Dia gnostics.Proces s.StartWithShel lExecuteEx(Proc essStartInfo
>startInf o)
>>
>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
>



Jul 27 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
4877
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
2
4544
by: jcrouse | last post by:
I apologize for starting another thread but the old one had a weird subject line. Anyways...here is the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strInput As String = Application.StartupPath & "\CreateMameGamesCFG.bat" If lblMameExePath.Text <> "" Then
3
5329
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look at it and let me know what I need to change. I have tried changing the "hwnd" type into intptr's but there seem to be other problems too, like it won't allow "lParam As Any" to be declared.
5
2122
by: Chris Austin | last post by:
I am trying to use the Shell command to run the MSDE setup. Shell("MSDE\setup.exe SAPWD=blah INSTANCENAME=TEST SECURITYMODE=SQL") This works in that it runs the setup, but the setup always pauses with a few seconds to go (as far as I can tell just before the MDAC install). If I then stop my VB.Net app, then the setup continues. Why is this happening and what can I do to resolve it? The same command works perfectly from the command...
7
7003
by: WALDO | last post by:
I wrote a console application that basically consumes arguments and starts other command line apps via System.Process. Let's call it XCompile for now. I wrote a Visual basic add-in that does pretty much the same thing to XCompile. Let's call it MyAddin. XCompile collects information to send to vbc.exe. When it comes across any arguments that are file paths, it wraps them in quotes. For example: Dim prms As String
2
6668
by: micahstrasser | last post by:
I have been trying for days to send a command to the command prompt through the shell() function in vb.net. For some reason it is not working. Here is the code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim command As String command = "systeminfo > C:\temp\sysinfo.txt"
0
2246
by: henning.friese | last post by:
Hello NG, I'm need to write some code which creates tiff files from various document types (doc, pdf, xls). I want to do this by ShellExecuting (via System.Diagnostics.Process) the doc-files with the "print"-verb. This works for me. However, I need to handle the case when a printing application doesnt't quit in a given timespan (for example a password-protected word-document). So I've tried the following:
9
1517
by: dave m | last post by:
I have a small application that launches an application via the shell function when a listening socket receives data from another PC. This works fine using a WinForms environment. However, I want this listing app to run in the background as a service. When debugging the service, the line - ID = Shell("C:\TestApp.exe", AppWinStyle.NormalFocus) returns a PID value, executes without errors, but the program "TestApp.exe"
5
7118
by: Rob R. Ainscough | last post by:
I'm using the Diagnostics.Process approach to shelling out run the following: C:\Windows\System32\MSIEXEC.EXE /x {73F1BDB7-11E1-11D5-9DC6-00C04F2FC33B} /q ..FileName = "C:\Windows\System32\MSIEXEC.EXE" ..Arguments = "/x {73F1BDB7-11E1-11D5-9DC6-00C04F2FC33B} /q" ..Start() I do a WaitForExit and get an error code back from MSIEXEC of 1605 -- this
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4181
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.