How can I run an .exe using C# from within the code behind of a WebForm app? 15 4251
mg <mg@discussions.microsoft.com> wrote: How can I run an .exe using C# from within the code behind of a WebForm app?
Where do you want to run the .exe? On the client, or the server? You
won't be able to do it on the client. To do it on the server, use
Process.Start.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
I put
System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe");
in Page_Load but notepad did not run. What did I do wrong?
"Jon Skeet [C# MVP]" wrote: mg <mg@discussions.microsoft.com> wrote: How can I run an .exe using C# from within the code behind of a WebForm app?
Where do you want to run the .exe? On the client, or the server? You won't be able to do it on the client. To do it on the server, use Process.Start.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
When you call the Start method on the Process class, it runs on the
server, so you now have an instance of notepad running on the server.
If you want this to run on the client, you will have to install an
ActiveX control, or a .NET control (with the appropriate security rights)
and then spawn the process from that. These controls will run in the client
context, and allow you to run programs on that.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com... I put
System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe");
in Page_Load but notepad did not run. What did I do wrong?
"Jon Skeet [C# MVP]" wrote:
mg <mg@discussions.microsoft.com> wrote: > How can I run an .exe using C# from within the code behind of a WebForm > app?
Where do you want to run the .exe? On the client, or the server? You won't be able to do it on the client. To do it on the server, use Process.Start.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
The code is run in Visual Studio .NET 2003 on my desktop, so I should see the
notepad ... I think ... ???
"Nicholas Paldino [.NET/C# MVP]" wrote: When you call the Start method on the Process class, it runs on the server, so you now have an instance of notepad running on the server.
If you want this to run on the client, you will have to install an ActiveX control, or a .NET control (with the appropriate security rights) and then spawn the process from that. These controls will run in the client context, and allow you to run programs on that.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message news:6B**********************************@microsof t.com...I put
System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe");
in Page_Load but notepad did not run. What did I do wrong?
"Jon Skeet [C# MVP]" wrote:
mg <mg@discussions.microsoft.com> wrote: > How can I run an .exe using C# from within the code behind of a WebForm > app?
Where do you want to run the .exe? On the client, or the server? You won't be able to do it on the client. To do it on the server, use Process.Start.
-- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
mg,
If you are hosting a web project in VS.NET 2003, or it is your machine,
then yes, it will show up on your desktop, because the server is on your
machine. However, for anyone outside of your machine connecting, it will
not work.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com... The code is run in Visual Studio .NET 2003 on my desktop, so I should see the notepad ... I think ... ???
"Nicholas Paldino [.NET/C# MVP]" wrote:
When you call the Start method on the Process class, it runs on the server, so you now have an instance of notepad running on the server.
If you want this to run on the client, you will have to install an ActiveX control, or a .NET control (with the appropriate security rights) and then spawn the process from that. These controls will run in the client context, and allow you to run programs on that.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message news:6B**********************************@microsof t.com... >I put > > System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe"); > > in Page_Load but notepad did not run. What did I do wrong? > > > "Jon Skeet [C# MVP]" wrote: > >> mg <mg@discussions.microsoft.com> wrote: >> > How can I run an .exe using C# from within the code behind of a >> > WebForm >> > app? >> >> Where do you want to run the .exe? On the client, or the server? You >> won't be able to do it on the client. To do it on the server, use >> Process.Start. >> >> -- >> Jon Skeet - <sk***@pobox.com> >> http://www.pobox.com/~skeet >> If replying to the group, please do not mail me too >>
I'm sorry, I wasn't clear. The problem is that I don't see notepad when I run
this line of code in Visual Studio .NET on my desktop ....
"Nicholas Paldino [.NET/C# MVP]" wrote: mg,
If you are hosting a web project in VS.NET 2003, or it is your machine, then yes, it will show up on your desktop, because the server is on your machine. However, for anyone outside of your machine connecting, it will not work.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message news:17**********************************@microsof t.com... The code is run in Visual Studio .NET 2003 on my desktop, so I should see the notepad ... I think ... ???
"Nicholas Paldino [.NET/C# MVP]" wrote:
When you call the Start method on the Process class, it runs on the server, so you now have an instance of notepad running on the server.
If you want this to run on the client, you will have to install an ActiveX control, or a .NET control (with the appropriate security rights) and then spawn the process from that. These controls will run in the client context, and allow you to run programs on that.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message news:6B**********************************@microsof t.com... >I put > > System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe"); > > in Page_Load but notepad did not run. What did I do wrong? > > > "Jon Skeet [C# MVP]" wrote: > >> mg <mg@discussions.microsoft.com> wrote: >> > How can I run an .exe using C# from within the code behind of a >> > WebForm >> > app? >> >> Where do you want to run the .exe? On the client, or the server? You >> won't be able to do it on the client. To do it on the server, use >> Process.Start. >> >> -- >> Jon Skeet - <sk***@pobox.com> >> http://www.pobox.com/~skeet >> If replying to the group, please do not mail me too >>
Not unless the ASP.NET worker process is running under the same
account as the logged in user (which it doesn't by default), or the
ASPNET account has additional privileges beyond the default.
The desktop is a secured resource and has an access control list. This
prevents some other logon from throwing up applications on a desktop
someone else owns.
Notepad will start, but will run in a non-interactive (invisible)
winstation.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Wed, 3 Nov 2004 14:36:00 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote: mg,
If you are hosting a web project in VS.NET 2003, or it is your machine, then yes, it will show up on your desktop, because the server is on your machine. However, for anyone outside of your machine connecting, it will not work.
--
Scott http://www.OdeToCode.com/
I've since formally deployed the simple one-line of code, which runs in the
Page_Load of a WebForm app, to IIS on Windows Server 2003.
The app runs without error but doesn't launch notepade. Anty thoughts?
System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe");
"mg" wrote: I'm sorry, I wasn't clear. The problem is that I don't see notepad when I run this line of code in Visual Studio .NET on my desktop ....
"Nicholas Paldino [.NET/C# MVP]" wrote:
mg,
If you are hosting a web project in VS.NET 2003, or it is your machine, then yes, it will show up on your desktop, because the server is on your machine. However, for anyone outside of your machine connecting, it will not work.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message news:17**********************************@microsof t.com... The code is run in Visual Studio .NET 2003 on my desktop, so I should see the notepad ... I think ... ???
"Nicholas Paldino [.NET/C# MVP]" wrote:
> When you call the Start method on the Process class, it runs on the > server, so you now have an instance of notepad running on the server. > > If you want this to run on the client, you will have to install an > ActiveX control, or a .NET control (with the appropriate security rights) > and then spawn the process from that. These controls will run in the > client > context, and allow you to run programs on that. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mv*@spam.guard.caspershouse.com > > "mg" <mg@discussions.microsoft.com> wrote in message > news:6B**********************************@microsof t.com... > >I put > > > > System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe"); > > > > in Page_Load but notepad did not run. What did I do wrong? > > > > > > "Jon Skeet [C# MVP]" wrote: > > > >> mg <mg@discussions.microsoft.com> wrote: > >> > How can I run an .exe using C# from within the code behind of a > >> > WebForm > >> > app? > >> > >> Where do you want to run the .exe? On the client, or the server? You > >> won't be able to do it on the client. To do it on the server, use > >> Process.Start. > >> > >> -- > >> Jon Skeet - <sk***@pobox.com> > >> http://www.pobox.com/~skeet > >> If replying to the group, please do not mail me too > >> > > >
I should add that I can see "notepad.exe" under Processes in Task Manager on
the server. Just no visible notepad app ???
"mg" wrote: I've since formally deployed the simple one-line of code, which runs in the Page_Load of a WebForm app, to IIS on Windows Server 2003.
The app runs without error but doesn't launch notepade. Anty thoughts?
System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe");
"mg" wrote:
I'm sorry, I wasn't clear. The problem is that I don't see notepad when I run this line of code in Visual Studio .NET on my desktop ....
"Nicholas Paldino [.NET/C# MVP]" wrote:
mg,
If you are hosting a web project in VS.NET 2003, or it is your machine, then yes, it will show up on your desktop, because the server is on your machine. However, for anyone outside of your machine connecting, it will not work.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"mg" <mg@discussions.microsoft.com> wrote in message news:17**********************************@microsof t.com... > The code is run in Visual Studio .NET 2003 on my desktop, so I should see > the > notepad ... I think ... ??? > > "Nicholas Paldino [.NET/C# MVP]" wrote: > >> When you call the Start method on the Process class, it runs on the >> server, so you now have an instance of notepad running on the server. >> >> If you want this to run on the client, you will have to install an >> ActiveX control, or a .NET control (with the appropriate security rights) >> and then spawn the process from that. These controls will run in the >> client >> context, and allow you to run programs on that. >> >> Hope this helps. >> >> >> -- >> - Nicholas Paldino [.NET/C# MVP] >> - mv*@spam.guard.caspershouse.com >> >> "mg" <mg@discussions.microsoft.com> wrote in message >> news:6B**********************************@microsof t.com... >> >I put >> > >> > System.Diagnostics.Process.Start("C:\\WINDOWS\\sys tem32\\notepad.exe"); >> > >> > in Page_Load but notepad did not run. What did I do wrong? >> > >> > >> > "Jon Skeet [C# MVP]" wrote: >> > >> >> mg <mg@discussions.microsoft.com> wrote: >> >> > How can I run an .exe using C# from within the code behind of a >> >> > WebForm >> >> > app? >> >> >> >> Where do you want to run the .exe? On the client, or the server? You >> >> won't be able to do it on the client. To do it on the server, use >> >> Process.Start. >> >> >> >> -- >> >> Jon Skeet - <sk***@pobox.com> >> >> http://www.pobox.com/~skeet >> >> If replying to the group, please do not mail me too >> >> >> >> >>
Could you tell me how I can give the ASPNET account additional privileges
beyond the default so that I can make notepad visible on the server?
"Scott Allen" wrote: Not unless the ASP.NET worker process is running under the same account as the logged in user (which it doesn't by default), or the ASPNET account has additional privileges beyond the default.
The desktop is a secured resource and has an access control list. This prevents some other logon from throwing up applications on a desktop someone else owns.
Notepad will start, but will run in a non-interactive (invisible) winstation.
-- Scott http://www.OdeToCode.com/blogs/scott/
On Wed, 3 Nov 2004 14:36:00 -0500, "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote:
mg,
If you are hosting a web project in VS.NET 2003, or it is your machine, then yes, it will show up on your desktop, because the server is on your machine. However, for anyone outside of your machine connecting, it will not work.
-- Scott http://www.OdeToCode.com/
>I should add that I can see "notepad.exe" under Processes in Task Manager on the server. Just no visible notepad app ???
Any application launched from a service will not have a UI because there is
no logical desktop to display it on. You are launching notepad from a
process that is authenticated as a windows (w3svc) service running in the
user account security context of IUSR_COMPUTERNAME. This user is not
"interactively logged on to a desktop" so nothing it launches has a place to
be displayed. The desktop that you are looking at on your screen is YOUR
user account security context, logged on interactively. They are two
totally different contexts.
--
Peace & happy computing,
Mike Labosh, MCSD
"I have no choice but to believe in free will."
> Could you tell me how I can give the ASPNET account additional privileges beyond the default so that I can make notepad visible on the server?
It's not an issue of privileges. The reason notepad is not visible on your
desktop is because the www service is a *service*, and therefore has no
access to the desktop. Therefore, anything it launches has no desktop.
--
Peace & happy computing,
Mike Labosh, MCSD
"I have no choice but to believe in free will."
About the safest way I can think to do this is to launch the process
from the service by PInvoking CreateProcessAsUser. This will allow you
to have the process run with your security credentials.
One of the many params to CreateProcessAsUser is a STARTUPINFO struct
which can tell the system what desktop to put the process on. By
specifying winsta0\default you can get the process to appear on the
desktop.
It just so happens I have some code to demonstate this: http://odetocode.com/Blogs/scott/arc...10/28/602.aspx
All you'd need to is change the line:
si.lpDesktop = String.Empty;
to
si.lpDesktop = @"winsta0\default";
Let me know if that helps.
P.S. I hope this is just for a local utility and not an actual
production web application.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Wed, 3 Nov 2004 12:49:12 -0800, "mg" <mg@discussions.microsoft.com>
wrote: Could you tell me how I can give the ASPNET account additional privileges beyond the default so that I can make notepad visible on the server?
Well, a service can have access to the desktop, for instance, services
running as LocalSystem can have access to the desktop if the "Allow
service to interact with desktop" option is selected, but that's
frowned upon because it's risky.
If the service is not LocalSystem it can still get to the desktop if
given access. This isn't something you can do with pure managed code,
it would take some pinvoking of stuff like SetSecurityDescriptorDacl
and SetUserObjectSecurity. An old technique in debugging least
privileged services was to temporarily give the desktop a null DACL,
essentially allowing anyone to throw something on the dekstop.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Wed, 3 Nov 2004 16:40:18 -0500, "Mike Labosh" <ml*****@hotmail.com>
wrote: Could you tell me how I can give the ASPNET account additional privileges beyond the default so that I can make notepad visible on the server?
It's not an issue of privileges. The reason notepad is not visible on your desktop is because the www service is a *service*, and therefore has no access to the desktop. Therefore, anything it launches has no desktop. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: William C. White |
last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using
cURL? Our website is hosted on a shared drive and the webhost company
doesn't installed additional software (such as cURL)...
|
by: Albert Ahtenberg |
last post by:
Hello,
I don't know if it is only me but I was sure that header("Location:url")
redirects the browser instantly to URL, or at least stops the execution of
the code. But appearantely it continues...
|
by: James |
last post by:
Hi,
I have a form with 2 fields.
'A'
'B'
The user completes one of the fields and the form is submitted.
On the results page I want to run a query, but this will change
subject to which...
|
by: Ollivier Robert |
last post by:
Hello,
I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9
system. The link succeeds but everytime I try to run php, I get a SEGV from
inside the libcnltsh.so library.
...
|
by: Richard Galli |
last post by:
I want viewers to compare state laws on a single subject.
Imagine a three-column table with a drop-down box on the top. A viewer
selects a state from the list, and that state's text fills the...
|
by: Albert Ahtenberg |
last post by:
Hello,
I have two questions.
1. When the user presses the back button and returns to a form he filled
the form is reseted. How do I leave there the values he inserted?
2. When the...
|
by: inderjit S Gabrie |
last post by:
Hi all
Here is the scenerio ...is it possibly to do this...
i am getting valid course dates output on to a web which i have designed
....all is okay so far , look at the following web url
...
|
by: Jack |
last post by:
Hi All,
What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g.
select x from y where z=:parameter
Which in asp/jsp would be followed by some statements to bind a value...
|
by: Sandwick |
last post by:
I am trying to change the size of a drawing so they are all 3x3.
the script below is what i was trying to use to cut it in half ... I
get errors.
I can display the normal picture but not the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |