c# - Execute a cmd file from IIS8 -


i have piece of code generates excel inbuilt functions

string xmlfilepath = "c:\\test\\standard_xml.xml"; string script = "c:\\test\\script.vbs";  string template = "template";  string cmdfilepath = @"c:\\test\\executable.cmd"; if (file.exists(cmdfilepath))   {     file.delete(cmdfilepath);   }   using (filestream fs = file.create(cmdfilepath))    {      byte[] info = new utf8encoding(true).getbytes("\"" + script + "\"" + " " +         "\"" + template + "\"" + " \"" + xmlfilepath + "\"");      fs.write(info, 0, info.length);    }      var process = process.start(cmdfilepath);     process.waitforexit(); 

this codes generates excel , required operations.

this works pretty fine when testing in visual studio, when run on iis8 never works. have tried various solutions mentioned on web nothing worked.

any appreciated.

without knowing sure (through error logs, eventvwr screenshots), guess you're running permissions issue.

when executing file-based operations iis, need keep in mind apppool identity being used website. apppool identity need have write permissions specific folder.

i suggest leaving apppool user identity built-in "applicationpoolidentity", secure option.

there lots of information on subject on msdn: https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities

specifically @ securing resources part how add file permissions: https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities#securing-resources

there other scenarios can override user account given apppool, , on website (for things impersonation, etc), if not doing those, above should work.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -