-1

I am executing this code from MVC website.If i run this code from VS 2012 IIS express it is working but if I host the website on IIS server, it does not work. I tried debugging but there is some error code coming. If I also impersonate my id and pass the my id but all in vain.

Code:

    System.Diagnostics.Process proc = new System.Diagnostics.Process();

    Char[] chr = Password.ToCharArray();

    System.Security.SecureString pwd = new System.Security.SecureString();

    foreach (char c in chr)
    {
        pwd.AppendChar(c);
    }

    proc.StartInfo.FileName = path to WZZip.exe

    //proc.StartInfo.Arguments = -ys20480 pathtosplit landingZone;  
    proc.StartInfo.UserName = UserName;  //Comes from config file
    proc.StartInfo.Password = pwd;        //Comes from config file
    proc.StartInfo.Domain = Domain;      //Comes from config file
    proc.StartInfo.RedirectStandardError = true;
    proc.StartInfo.RedirectStandardOutput = true;
    proc.StartInfo.UseShellExecute = false;
    bool result = proc.Start();
halfer
  • 19,824
  • 17
  • 99
  • 186
Sahil Gupta
  • 13
  • 1
  • 8

1 Answers1

1

When running a exe through iis You should start with the some questions:

A) Should I bypass built-in security that protects the IIS Server and Windows System ?

B) If you allow executables to run using paths into the OS or the IIS sever who else can use this ie "HAcker" ?

C) There have been changes to Windows and IIS Server to protect the system(s) from "Attacks" and to limit the Surface Area for exploits. What Security Monitoring is being done for the system & IIS Server ? What security protection will you implement for your executable ?

If you can justify the risks for A - C you can "Work Around" the restrictions.

If you understand the Risks Technet has tools to help with some of the issues http://blogs.technet.com/b/elevationpowertoys/ .

For Windows Vista Windows 7 Windows 2008 you have the Standard User and limits for Permissions and Rights

a thread http://forums.iis.net/p/1178151/1981859.aspx#1981859 for who can do what.

You can Search (Goole or Bing) for "Changes to Windows Destop Security" "Session(0) changes and impacts for Systems & Services"

you also can get a copy of the "Vista Developer Story" from Microsoft Download Center.

You should check the MSDN library for Application Compatability and how to Design using User Access Control (UAC).

Many of the security changes have been added to Windows 2003 and IIS 6.0 server.

Finally u can Add MIME Types in IIS

  • Open IIS Manager.

  • Browse to the IIS Site or subfolder where the ThinApp EXE .

  • Right click on that site or subfolder and select PROPERTIES.

  • Select the HTTP HEADERS tab.

  • Click on the MIME TYPES button.

  • In the extension box, type ".exe".

  • In the MIME TYPE box, type "application/octet-stream".

  • Click OK.

Niventh
  • 985
  • 2
  • 9
  • 23
  • i have checked this one also...but still not able to execute that code.i am already impersonating my id – Sahil Gupta Mar 16 '15 at 14:50
  • you can add ".exe" MIME Types and try – Niventh Mar 16 '15 at 14:53
  • where i did not understand – Sahil Gupta Mar 16 '15 at 14:54
  • Add MIME Types in IIS Open IIS Manager. Browse to the IIS Site or subfolder where the ThinApp EXE . Right click on that site or subfolder and select PROPERTIES. Select the HTTP HEADERS tab. Click on the MIME TYPES button. In the extension box, type ".exe". In the MIME TYPE box, type "application/octet-stream". Click OK. – Niventh Mar 16 '15 at 14:57
  • This exe is winzip exe and installed at server. The user tries to click on the button and this exe should run. I have not put this exe in some subfolder of website. – Sahil Gupta Mar 16 '15 at 14:59
  • when IIS try to execute the .exe that time IIS check the file extension. so u need to add the MIME type. once you can add the MIME type and try again – Niventh Mar 16 '15 at 15:05
  • and also you need to give the full permission to Network Service user – Niventh Mar 16 '15 at 15:07
  • @SahilGupta - WinZip is a GUI application, and as such tries to open a window. IIS does not allow applications to do that because they run in a headless operation mode. You will need a command line only zip application, or better yet, use a library like SharpZipLib – Erik Funkenbusch Mar 16 '15 at 15:07
  • The exe i am calling is just a command given by winzip in exe format – Sahil Gupta Mar 16 '15 at 15:12
  • Go and check event viewer. wat error you got post it here – Niventh Mar 16 '15 at 15:18