如何禁用打开文件–安全警告 [英] How to disable Open file – Security warning

查看:221
本文介绍了如何禁用打开文件–安全警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题。
我已经编写了一个winform服务器应用程序和一个winform客户端应用程序。
客户端的作用是向服务器发送用于运行特定脚本的命令。
服务器接收这些命令,解析它们并运行它们。



这两个命令很好用。



<我已经编写了一个cmd应用程序,该应用程序使用了客户端的一些功能。该应用程序应该用作cmd客户端。



问题是这样的:当我运行winform客户端时,服务器运行命令完全没有问题。
运行cmd客户端时,当服务器尝试执行接收到的命令时,服务器端的Windows会弹出有关是否可以运行脚本的安全性问题(请参见附件图像)。



为什么会在cmd而不是winform上发生。



这是我的代码:

 使用系统; 
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用Microsoft.Win32;
使用System.Net.Sockets;
使用System.ComponentModel;
使用System.IO;
使用System.Management;

名称空间RemoteBatcher
{
类ClientCmdProgram
{
private静态RegistryKey RegistryKey;
private static Socket clientSock;
私有静态字符串remoteIpAddress = 192.168.0.1;
private static int remotePort = 8;
私有静态字符串userName =;
私有静态字符串targetPath = Z:\\nBatcher\\;
private static List< string> listOfCommands = new List< string>();

静态void Main(string [] args)
{
var backgroundWorker = new BackgroundWorker();
userName = RemoteUtils.getConnectedUser();
RegistryKey = Registry.CurrentUser.OpenSubKey( Key);

if(registryKey == null)
{
Console.WriteLine(错误!在注册表中未找到保存的数据。请先运行RemoteBatcherClient应用。);
Environment.Exit(1);
}

if(!connectToServer(backgroundWorker))
Environment.Exit(1);

getCommandsList();
sendCommands(backgroundWorker);
}
私有静态布尔connectToServer(BackgroundWorker backgroundWorker)
{
try
{
clientSock = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType .tcp);
clientSock.Connect(remoteIpAddress,remotePort);
backgroundWorker.DoWork + =(sender1,e1)=> RemoteUtils.copyDllsToServer(targetPath + = userName);
backgroundWorker.RunWorkerAsync();
}
catch(异常例外)
{
Console.Write(ex.Message);
返回false;
}

返回true;
}
私有静态无效getCommandsList()
{
string [] commandsInRegistry = registryKey.GetValueNames();

for(int i = 0; i< commandsInRegistry.Length; i ++)
{
listOfCommands.Add(registryKey.GetValue(commandsInRegistry [i])。ToString() );
}
}
private static void sendCommands(BackgroundWorker backgroundWorker)
{
int flicker = 100;
int计数器= 100;
试试
{

而(backgroundWorker.IsBusy)
{
if(counter == flicker)
{
counter = 1;
Console.WriteLine(正在复制可执行文件,请稍候..);
}
else if(counter == 50)
{
Console.Clear();
}
else
counter ++;
}

for(int i = 0; i< listOfCommands.Count; i ++)
{
clientSock.Send(Encoding.Default.GetBytes(listOfCommands [ i] +< eom>));
}
clientSock.Close();
clientSock.Dispose();
}
catch(异常例外)
{
Console.Write(ex.Message);
Environment.Exit(1);
}

}
}
}

有什么想法吗?

解决方案

如何在Windows XP中禁用打开文件-安全警告?



要禁用警告,请启动组策略编辑器(开始>运行,键入
-gpedit.msc-并按OK),然后转到:



-用户配置>管理模板> Windows组件>
附件管理器-然后将低文件类型的包含列表设置为
已启用,并在
框中输入您不想被警告的文件类型(例如:.exe) 。


I have a weird question. I have written a winform server application and a winform client application. The role of the client is to send commands for running a certain script to the server. The server receives those commands, parses them, and runs them.

These two work great.

I have written a cmd application which uses some of the functions from my client. This application is supposed to function as a cmd client.

The question is this: When I run the winform client, the server runs the commands with no problems at all. When I run the cmd client, when the server attempts to execute the received command, Windows on the server side pops up the security question of whether the script can be run or not (see attached image).

Why does it happen on the cmd and not on the winforms.

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Net.Sockets;
using System.ComponentModel;
using System.IO;
using System.Management;

namespace RemoteBatcher
{
    class ClientCmdProgram
    {
        private static RegistryKey registryKey;
        private static Socket clientSock;
        private static string remoteIpAddress = "192.168.0.1";
        private static int remotePort = 8;
        private static string userName = "";
        private static string targetPath = "Z:\\nBatcher\\";
        private static List<string> listOfCommands = new List<string>();

        static void Main(string[] args)
        {
            var backgroundWorker = new BackgroundWorker();
            userName = RemoteUtils.getConnectedUser();            
            registryKey = Registry.CurrentUser.OpenSubKey("Key");

            if (registryKey == null)
            {
                Console.WriteLine("Error! No Saved Data Was Found In The Registry. Please Run The RemoteBatcherClient App First.");
                Environment.Exit(1);
            }

            if (!connectToServer(backgroundWorker))
                Environment.Exit(1);

            getCommandsList();
            sendCommands(backgroundWorker);
        }
        private static bool connectToServer(BackgroundWorker backgroundWorker)
        {
            try
            {
                clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                clientSock.Connect(remoteIpAddress, remotePort);
                backgroundWorker.DoWork += (sender1, e1) => RemoteUtils.copyDllsToServer(targetPath += userName);
                backgroundWorker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                return false;
            }

            return true;
        }
        private static void getCommandsList()
        {
            string[] commandsInRegistry = registryKey.GetValueNames();

            for (int i = 0; i < commandsInRegistry.Length; i++)
            {
                listOfCommands.Add(registryKey.GetValue(commandsInRegistry[i]).ToString());
            }
        }
        private static void sendCommands(BackgroundWorker backgroundWorker)
        {
            int flicker = 100;
            int counter = 100;
            try
            {

                while (backgroundWorker.IsBusy) 
                {
                    if (counter == flicker)
                    {
                        counter = 1;
                        Console.WriteLine("Copying Executable Files, Please Wait..");
                    }
                    else if (counter == 50)
                    {
                        Console.Clear();
                    }
                    else
                        counter++;
                }

                for (int i = 0; i < listOfCommands.Count; i++)
                {
                    clientSock.Send(Encoding.Default.GetBytes(listOfCommands[i] + " <eom> "));
                }
                clientSock.Close();
                clientSock.Dispose();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                Environment.Exit(1);
            }

        }
    }
}

Any ideas?

解决方案

How can i disable open file - security warning in windows xp ?

To disable the warning start the Group Policy Editor (Start > Run, type -gpedit.msc- and press OK) and go to:

-User Configuration > Administrative Templates > Windows Components > Attachment Manager- then set -Inclusion list for low file types- to Enabled and enter the file types you don't want to be warned about in the box (for example: .exe).

这篇关于如何禁用打开文件–安全警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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