有没有办法使用C#代码在IIS中运行客户端程序/运行批处理文件?

时间:2023-01-25 02:06:35

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 fail. The coding i use which is

我有一个任务是在IIS中运行批处理文件。我使用C#开发了一个网页,需要运行批处理文件并使用plink在命令中执行批处理文件。我曾尝试过localhost,它运行得很好。但是,当我部署到IIS时,它失败了。我使用的编码是

Process.Start(@"C:\run.bat");
inside run.bat is

的Process.Start(@ “C:\ run.bat中”);在run.bat里面

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

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通过

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.

我使用C#代码创建批处理文件,批处理文件将存储在IIS中,然后在IIS中执行批处理文件只返回成功的消息给客户端。

Which mean everything done in server IIS. Is there anyway to do it??

这意味着在服务器IIS中完成的一切。无论如何要做到这一点?

Thanks in advance.

提前致谢。

1 个解决方案

#1


0  

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" />

在这个文件夹C:\ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG中,有一个文件调用Machine.config。用notpad打开。按Ctrl + F并搜索processModel,然后你会发现这个标签 。将其更改为

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#).

我希望这有帮助,因为他们中的许多人正在寻找这个问题(在C#中运行Process.Start())。

Good Luck!!

#1


0  

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" />

在这个文件夹C:\ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ CONFIG中,有一个文件调用Machine.config。用notpad打开。按Ctrl + F并搜索processModel,然后你会发现这个标签 。将其更改为

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#).

我希望这有帮助,因为他们中的许多人正在寻找这个问题(在C#中运行Process.Start())。

Good Luck!!