html cmd命令,没有窗口的html cmd或powershell命令

如果你想在html文件或你的网站中运行脚本或bat文件想要运行脚本你可以使用visual studio并添加名为PowerShellExecution的Web应用程序default.aspx

 

PowerShell Command Harness

  
 PowerShell Command
 

Result

工具菜单选择库包管理器>>包管理器控制台包管理器控制台执行“Install-Package System.Management.Automation”成功执行该包安装后,您将要添加对Default.aspx.cs文件的引用:

using System.Management.Automation;

在你的Default.aspx.cs中

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Management.Automation;

using System.Text;

namespace PowerShellExecution

{

public partial class Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void ExecuteCode_Click(object sender, EventArgs e)

{

// Clean the Result TextBox

ResultBox.Text = string.Empty;

// Initialize PowerShell engine

var shell = PowerShell.Create();

// Add the script to the PowerShell object

shell.Commands.AddScript(Input.Text);

// Execute the script

var results = shell.Invoke();

// display results, with BaseObject converted to string

// Note : use |out-string for console-like output

if (results.Count > 0)

{

// We use a string builder ton create our result text

var builder = new StringBuilder();

foreach (var psObject in results)

{

// Convert the Base Object to a string and append it to the string builder.

// Add \r\n for line breaks

builder.Append(psObject.BaseObject.ToString() + "\r\n");

}

// Encode the string in HTML (prevent security issue with 'dangerous' caracters like < >

ResultBox.Text = Server.HtmlEncode(builder.ToString());

}

}

}

}

“PowerShell命令”窗口Get-EventLog安全性 - 最新10(或您最喜欢的cmdlet用于测试) . 或者把脚本放在那只是改变

//shell.Commands.AddScript(Input.Text);

shell.Commands.AddScript("C:\\Scripts\\PowerShell\\PowerShellScript.ps1")

但对于运行脚本,您应该在PowerShell 32位和64位64位中运行Set-ExecutionPolicy旁路

C:\Windows\System32\WindowsPowerShell\v1.0

32位

C:\Windows\SysWOW64\WindowsPowerShell\v1.0

你应该运行visual studio并在你的iis中发布非常简单,为你可以使用的dns添加功能iis

C:\Windows\System32\drivers\etc

在主机文件中

127.0.0.1 soheil.com

我希望我理解你的需要问候

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值