防火墙打开时强制远程关闭Windows XP [英] Force remote shutdown windows xp when firewall is on

查看:161
本文介绍了防火墙打开时强制远程关闭Windows XP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我将此代码用于Windows XP的远程关闭.
我发现系统的防火墙处于打开状态,因此无法连接到系统.如何强制关闭该系统?

Hi ,

I used this code for remote shutdown windows XP.
I found system''s firewall is On, and thus it is unable to connect to system. How can I force shut down this system ?

ManagementScope Scope = null;
ConnectionOptions ConnOptions = null;
ObjectQuery ObjQuery = null;
ManagementObjectSearcher ObjSearcher = null;
try
{
    ConnOptions = new ConnectionOptions();
    ConnOptions.Impersonation = ImpersonationLevel.Impersonate;
    ConnOptions.EnablePrivileges = true;
    //local machine
    if (machineName.ToUpper() == Environment.MachineName.ToUpper())
    {
        Scope = new ManagementScope(@"\ROOT\CIMV2", ConnOptions);
    }
    else
    {
        ConnOptions.Username = username;
        ConnOptions.Password = password;
        Scope = new ManagementScope(@"\\" + machineName + @"\ROOT\CIMV2",  ConnOptions);
    }
    Scope.Connect();
    ObjQuery = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
    ObjSearcher = new ManagementObjectSearcher(Scope, ObjQuery);
    foreach (ManagementObject operatingSystem in ObjSearcher.Get())
    {
        MessageBox.Show("Caption = " + operatingSystem.GetPropertyValue("Caption"));
        MessageBox.Show("Version = " + operatingSystem.GetPropertyValue("Version"));
        ManagementBaseObject outParams = operatingSystem.InvokeMethod("Shutdown",null, null);
    }
}



我需要一个代码来关闭计算机力量
有时无法更改防火墙设置.
我试图使用shutdown.exe关闭计算机.但它是访问被拒绝"



I need a code to shut down computer force
sometimes it is impossible to change the firewall setting .
i tried to shutdown computer with shutdown.exe . but it is "access denied"

推荐答案

没有奇迹.防火墙列出了每个方向上允许的协议以及每个协议允许的端口.您要么需要开发/配置服务,要么客户端需要使用允许的协议/端口组合并更改防火墙设置.

-SA
There is no such thing as miracle. Firewalls list allowed protocols in each direction with allowed ports on each protocol. You either need to develop/configure your service and your client to use allowed combination of protocol/port and change firewall settings.

—SA


我仍然使用 PSShutDown [ ^ ]


这也可能会遇到防火墙问题,需要打开端口445

http://forum.sysinternals.com/psshutdown-and-firewall_topic14207.html [ ^ ]

仍然是装备中的绝佳工具
I still use PSShutDown[^]


This can also face firewall issues, it needs port 445 open

http://forum.sysinternals.com/psshutdown-and-firewall_topic14207.html[^]

Still, great tool to have in your armoury


shell("Shutdown.exe -s -t 00")
shell("Shutdown.exe -s -t 00")


这篇关于防火墙打开时强制远程关闭Windows XP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆