Is there any way to use C# code to run client program/ run a batch file in IIS?
I have a task which is to run a batch file in IIS.. I had use C# to develop a webpage which need to run a batch file and uses plink to execute the batch file in the command. I had tried in localhost and it works perfectly. But when i deploy to IIS, it开发者_Python百科 fail. The coding i use which is
Process.Start(@"C:\run.bat");
run.bat
is
cd\
plink root@172.28.8.* -pw ServerPassword useradd USERNAME -p UserPassword -m -g groupname -e 2011-6-6 -s /bin/bash -c *FULL_NAME* plink root@172.28.8.* -pw ServerPassword -m pass
Is there any other way to do this?? or is there anyway something like this
i create the batch file using C# code, the batch file will store in IIS, then execute the batch file in IIS only return a successful message to the client.
Which mean everything done in server IIS. Is there anyway to do it??
Thanks in advance.
i have found the solution.
Inside this folder C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
, there is a file call Machine.config
. Open with a notpad. Ctrl+F and search for processModel, then you will find this tag <processModel autoConfig="true"/>
. Change it to <processModel userName="SYSTEM" password="AutoGenerate" />
As shown here .Then save it, make sure you backup a copy first, in case of maybe there are some errors occur.
I hope this help as many of them is searching for this problem(run Process.Start() in C#).
Good Luck!!
精彩评论