3

I wrote a program using C# and make exe file using advanced installer and it work good but i want to make this exe file work in one computer, because some clints take exe and give this exe to another and i want to privint that and protect my works

  • 4
    I guess thats why licenses was invented – andreasnico Mar 10 '16 at 10:59
  • 1
    This question has too many possible answers to be of use. Make them enter a password, check the MAC address of a certain piece of hardware, use some kind of third party license system, etc etc – Equalsk Mar 10 '16 at 11:03

4 Answers4

3

run the code below on the machine that you want your .exe. file to work on (it will give you this machines MAC address). 2. Add this MAC address to the code below 3. Add the code below to your C# code to ensure that it only runs on the machine with the correct MAC address (unique)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;

namespace OneMachine
{
    class Program
    {
        static void Main(string[] args)
        {

            string clientMAC = "XX-XX-XX-XX-XX-XX";       //  put the correct value here when you know it
            string thisComputerMAC = GetMACAddress2();

            Console.WriteLine("MAC:" + thisComputerMAC);   // remove this when necessary

            if (clientMAC == thisComputerMAC)
            {

                Console.WriteLine("this is the right computer");
            } else
            {
                Console.WriteLine("PROGRAM WONT RUN ON THIS COMPUTER");
            }


        }

        public static string GetMACAddress2()
        {
            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            String sMacAddress = string.Empty;
            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty)// only return MAC Address from first card  
                {
                    //IPInterfaceProperties properties = adapter.GetIPProperties(); Line is not required
                    sMacAddress = adapter.GetPhysicalAddress().ToString();
                }
            } return sMacAddress;
        }


    }
}

reference: C# Get Computer's MAC address "OFFLINE"

Community
  • 1
  • 1
Grant Shannon
  • 4,709
  • 1
  • 46
  • 36
  • My program shows different Mac I'd when it's offline, and when it connects to diff networks. Any idea why is that ? – mrid Oct 26 '18 at 12:42
1

I think what you want would be some sort of licence key and an authorization method.

A quick google turned up this article which you may find useful.

http://www.codeproject.com/Articles/28678/Generating-Unique-Key-Finger-Print-for-a-Computer

monkeylumps
  • 747
  • 4
  • 10
  • 23
0

u can create the security constrain for exe like

  1. by Giving unique password
  2. By Entering the serial Key i.e. Licence Key which will know to u only or create random serial key generator based on the system.
Tanmay Nehete
  • 2,138
  • 4
  • 31
  • 42
0

You can allow only one user run your program by using a hardware ID to identify the user using the application or you can use a licensing system.

Ben
  • 176
  • 1
  • 1
  • 14