Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Open file – Security warning

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?

like image 849
Idanis Avatar asked Feb 05 '13 08:02

Idanis


People also ask

How do I turn off open file security warnings in Windows 11?

Open Internet Options. Navigate to the Security tab, select Local intranet, and click on Sites button. The local intranet window will appear. Uncheck all options except Include all network paths (UNCs).

What happens if I disable open file-security warning?

Disabling Open File - Security Warning will reduce the security level of Windows, and place your computer at a higher risk of being infected by malware. Disable at your own risk if you no longer want to have a Open File - Security Warning. Do you want to open this File?

How to remove “open file security warning” in Windows 10?

Step 1) Firstly, go ahead and click open the program that shows the Open File Security Warning prompt every time you launch. Step 2) Now, you only have to uncheck the box of the Always ask before opening this file option.

How do I get rid of a security warning on Windows?

Right-click the problematic file and choose Properties from the menu. When the Properties window opens, go to the General tab and click on the Unblock button. To stop this security warning from appearing, you might need to unblock your file. Sometimes files can become blocked causing this warning to appear.

How to avoid the Windows security window when opening a file?

Only run software from publishers you trust. If you uncheck the option “ Always ask when opening this file ”, then the next time you run this file, the Windows security window will not appear. But in this way, you will have to add programs to exceptions manually.


1 Answers

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

like image 194
Yaqub Ahmad Avatar answered Oct 13 '22 10:10

Yaqub Ahmad