我使用netsh将我的应用程序添加到防火墙,如下所示.在将其添加到防火墙之前,如何知道应用程序尚未添加到防火墙?因为我不想反复将我的应用程序添加到防火墙.
ProcessStartInfo info = null;
try
{
using (Process proc = new Process())
{
string productAssembly = new Uri(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase)).LocalPath + "\\" + this.ProductName + ".exe";
string args = string.Format(CultureInfo.InvariantCulture, "advfirewall firewall add rule name=\"{0}\" dir=in action=allow program=\"{1}\" enable=yes", this.ProductName, productAssembly);
info = new ProcessStartInfo("netsh", args);
proc.StartInfo = info;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Run Code Online (Sandbox Code Playgroud) 我使用netsh wlan set hostednetwork命令创建了一个托管网络,我可以将它与我的设备连接.现在我想用这个托管网络连接我的新手机,但我不记得我设置的密码.
我可以设置新的托管网络并将我的设备连接到该网络.但我很想知道
我正在尝试用 netsh 编写一些简短的脚本。一种是将适配器更改为静态寻址,一种将同一适配器更改回 DHCP。
我可以使用所有正确的静态地址设置来获取适配器集
netsh interface ip set address "Local Area Connection" static 10.61.1.253 255.255.255.0 10.61.1.1 1
Run Code Online (Sandbox Code Playgroud)
这很好用。当我运行以下命令(脚本)切换回 DHCP 时,我收到一条错误消息。
netsh interface ip set address "Local Area Connection" dhcp
Run Code Online (Sandbox Code Playgroud)
该接口上已启用 DHCP。
这是在 Windows 7 计算机上。
知道问题是什么吗?
我有一个NT调用Delphi 7编写的控制台程序的服务,让我们调用它failover.exe,然后NETSH使用我发现的程序调用:
procedure ExecConsoleApp(CommandLine: ansistring; Output, Errors: TStringList);
Run Code Online (Sandbox Code Playgroud)
注意:ExecConsoleApp使用CreateProcess,请参阅以下链接获取完整代码:http://www.delphisources.ru/pages/faq/base/createprocess_console.html
我会在调用之前将以下内容传递给CommandLine ExecConsoleApp:
cmd.exe /c "C:\Windows\system32\netsh.exe interface delete address "Wireless Network Connection" 192.168.0.36"
Run Code Online (Sandbox Code Playgroud)
ExecConsoleApp 将返回错误:
该系统找不到指定的文件
但是,如果我在命令提示符下运行它,它运行完美.
奇怪的是,我记得它在2003 Server上的第一次尝试工作,但在那之后,无论我尝试多少次都失败了.在其中一次尝试中,我还尝试将登录作为管理员用户分配给服务但无济于事.也没有摆弄文件安全帮助.
我没有Win 2003服务器在办公室进行测试,但我已经在XP和Win7上测试过它并且ExecConsoleApp工作得很好,虽然在XP上,我不得不修改ExecConsoleApp执行system32\wbem以便它工作:
Res := CreateProcess(nil, PChar(CommandLine), nil, nil, True,
// **** Attention: Amended by to point current directory to system32\wbem, this is to solve an error returned by netsh.exe if not done otherwise.
// CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 Windows 7 64 位系统上的 .bat 或 .jar 文件运行“netsh mbn show interfaces”,但每次运行我的文件时,都会导致“找不到以下命令 mbn show interfaces”。
当我在 cmd.exe 提示符下运行相同的命令时,结果是正确的并且符合预期。当我们运行 /? 我们在可用命令中看到“mbn”。当我们从 .bat 或 .jar 输出相同的结果时,我们在 netsh 的可用命令中看不到“mbn”命令。
有人知道这是怎么回事吗?我们知道有 2 个 netsh.exe 文件,一个在 sys32 中,一个在 syswow64 中。
感谢所有帮助。
我使用IIS Express作为我的Visual Studio 2012开发Web服务器.我希望能够通过无线设备(智能手机,平板电脑等)访问我的网站进行测试和调试.无线设备与工作站位于不同的LAN上,不属于我的Windows AD.由于办公室局域网的设置方式,他们无法通过主机名解析我的工作站; 他们必须使用IP地址.
为了能够通过非本地主机URL访问IIS Express,我必须在applicationhost.config中更改其配置以添加使用该IP地址的绑定,然后用于netsh http add urlacl...进行URL保留.
如果我使用预留中的IP地址和applicationhost.config,我可以使它正常工作.但IP地址偶尔也会发生变化.有没有办法使用通配符语法,因此它适用于任何IP地址?我试过这些:
netsh http add urlacl url=http://+:49197/ user=everyone
和
netsh http add urlacl url=http://*:49197/ user=everyone
但是,当我尝试启动IIS Express时,它抱怨它无法启动,因为访问被拒绝.
什么是正确的语法?
我正在尝试使用两个 WIFI 适配器来组成一个 WLAN 网络。我知道以下命令可以设置托管网络,而且我已经完成了。
netsh wlan set hostednetwork [[mode={allow|disallow}] [[ssid=]WirelessNetworkName] [[key=]passphrase] [[keyUsage=]{persistent|temporary}]
netsh wlan start hostednetwork
Run Code Online (Sandbox Code Playgroud)
但是,我设置的托管网络会自动镜像到第一个适配器。如何设置另一个镜像到第二个适配器的托管网络?我在互联网上搜索了很长时间,但仍然没有得到解决方案。谢谢。
我已经将RavenDB 2.5.0安装为Windows服务.当我尝试以管理员身份运行Raven.Server.exe时,我会收到:
Trying to revoke rights for http.sys
runas netsh http delete urlacl url=https://+:8080/
Trying to grant rights for http.sys
runas netsh http add urlacl url=http://+:8080/ user="Endri-PC\Endri"
Failed to grant rights for listening to http, exit codes: (1 and 1)
A critical error occurred while starting the server. Please see the exception de
tails bellow for more details:
System.InvalidOperationException: Could not write to location: C:\RavenDB\Databa
se\System. Make sure you have read/write permissions for this path. ---> Microso
ft.Isam.Esent.Interop.EsentFileAccessDeniedException: Cannot access …Run Code Online (Sandbox Code Playgroud) 因此,我目前正在尝试创建一个批处理文件来连接到无线网络。到目前为止我有以下...
@echo off
netsh wlan connect ssid="My SSID" name="My Name"
pause
Run Code Online (Sandbox Code Playgroud)
它工作正常,但问题是它只能连接到我的配置文件中已有的网络。有什么方法可以使用密码作为参数连接到无线网络,而我的配置文件中尚未包含该密码吗?
过去,我会通过运行以下命令来注册应用程序的 SSL 证书:
netsh http add sslcert ipport=1.2.3.4:443 certhash=a4e9de3a1610ec4eae82fa81444061b8 appid={8792bd09737f8b48991bfce5c15f3700}
其中“appid”GUID 来自 AssemblyInfo.cs 中的“程序集:Guid”属性。但是对于新的.Net Core应用程序,没有AssemblyInfo.cs,那么我从哪里获取这个appid呢?
netsh ×10
cmd ×3
c# ×2
networking ×2
windows ×2
.net-core ×1
32bit-64bit ×1
batch-file ×1
delphi ×1
firewall ×1
http.sys ×1
iis-express ×1
ravendb ×1
ravendb-http ×1
windows-7 ×1
winforms ×1
wlan ×1