November Wallpaper L’Impero dei Draghi (3)

I’ve packed both MV Executer service and MVPrivilegedExecuter class library for you convenience in a setup package:

Download

Download MV Executer (2008/10/08)
[downloaded 216 times]

System Requirements

  • Microsoft .net Framework 2.0 or later (freely available here)
  • Asp.net 1.1 or later

Configuration

Before start using MV Executer you need to perform two tasks:

  • Edit the MV Executer service configuration file to set the IPC file location
  • Change the MV Executer service Log on account

MV Executer service configuration file

For simplicity all configuration options for the MV Executer service are set by editing the file MV Executer.exe.config, that is located in the software installation folder (it can be accessed also from Start > All Programs> MV Executer > MV Executer configuration file. (Note: after editing the file, it is necessary to restart the MV Executer service so that the new configuration becomes effective. Eventual problems or notifications are visible in the System Event Viewer - Application section).

TheMV Executer.exe.config file is an XML file, basically you only need to edit the inter-process communication file location, to reflect a folder on which your running asp.net account has write/modify permissions, on line 11:


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="MV_Executer___.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <MV_Executer___.Properties.Settings>
            <setting name="CommandFile" serializeAs="String">
                <value>c:\aspnet_writable_folder\MVExecuterIPC.txt</value>
            </setting>
            <setting name="DEBUG_LEVEL" serializeAs="String">
                <value>3</value>
            </setting>
            <setting name="CommandSeparator" serializeAs="String">
                <value>|||</value>
            </setting>
        </MV_Executer___.Properties.Settings>
    </applicationSettings>
</configuration>

Change the MV Executer service Log on account

To perform this task, do

  • Start > Control Panel > Administrative Tools > Services;
  • Locate MV Executer, then double click on it;
  • On the opened window go to Log On tab, then check "This account" and insert your administrator (or preferred other user) username and password;
  • Click Apply
  • Go to General tab, and click on Start button.

Usage on your asp.net pages

To use MV Executer in your asp.net pages:

  • Be sure that the MV Executer service is running and correctly configured
  • Copy MVPrivilegedExecuter.dll file into your webserver bin directory (usually <webserver_root_directory>\bin)
  • Follow the reference below:

MVPrivilegedExecuter.dll reference

MV.MVPrivilegedExecuter

public static bool Execute(string IPCFile, string ApplicationToExecute, string ApplicationArguments, out string ErrorMessage)

Summary:

Executes a command/application with administrator privileges by invoking the MV Executer service

Parameters:

IPCFile:
Full path and name of inter-process communication file
ApplicationToExecute:
Full path and name of the command/application to be executed
ApplicationArguments:
Optional parameters to be passed to the application. Use "" for empty
ErrorMessage:
out string that receive a descriptive message in case of errors

Returns:

true on successful invokation, false on failure

Examples:

<%@ Page Language="C#" %>
<%@ Assembly Name="MVPrivilegedExecuter" %> 

<%

string s;

if (! MV.MVPrivilegedExecuter.Execute(
	@"c:\aspnet_writable_folder\MVExecuterIPC.txt", "notepad.exe", "", out s
    )
	)
{
    Response.Write("Error invoking MV Executer: " + s);
}

%>

 

That’s it! Let me know if you have found it somewhat useful.

Please consider supporting this project with a donation if it has been helpful to you.
Warning. The content of this article, and related downloads, is provided as-is; use at your own risk; no warranty; no promises; enjoy!
For more informations, please consult my disclaimer page.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Technorati
  • Sphinn
  • Facebook
  • LinkedIn
  • Live
Pages: 1 2 3
Improve Microon Lounge rating this post
Tell me what do you think about "Run commands with administrator privileges from asp.net page": I'll write better and better entries.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading ... Loading ...

Leave a Reply


your name
your e-mail address
your website/url

Isn't this worth at least €1?

Any donation is appreciated, consider a €1 donation for each download (or maybe €1.35 since PayPal takes €0.35 from a €1.00 donation). Your support allows me to continue to create free software.