SystemRage / py-kms

KMS Server Emulator written in Python
The Unlicense
2.04k stars 618 forks source link

py-kms logs in windows #28

Closed rezafathikohi closed 5 years ago

rezafathikohi commented 5 years ago

Hello,

I used this tutorial to run py-kms on windows and everything works fine but I want py-kms server to create logs about computers which connected to it and activated. So, How can I do that?

**** I can not activate windows where py-kms is installed. Why?

Download and install: https://www.python.org/ftp/python/2.7.14/python-2.7.14.amd64.msi (into C:\Windows\Python27) https://github.com/mhammond/pywin32/releases/download/b222/pywin32-222.win-amd64-py2.7.exe

Download and extract py-kms-master.zip into C:\Windows\Python27\py-kms cd C:\Windows\Python27\py-kms\

Create file kms-winservice.py and put into file this code:

import win32serviceutil import win32service import win32event import servicemanager import socket import subprocess

class AppServerSvc (win32serviceutil.ServiceFramework): _svcname = "py-kms" _svc_displayname = "py-kms" _proc = None _cmd = ["C:\Windows\Python27\python.exe", "C:\Windows\Python27\py-kms\server.py"]

def __init__(self,args):
    win32serviceutil.ServiceFramework.__init__(self,args)
    self.hWaitStop = win32event.CreateEvent(None,0,0,None)
    socket.setdefaulttimeout(60)

def SvcStop(self):
    self.killproc()
    self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
    win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self):
    servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                          servicemanager.PYS_SERVICE_STARTED,
                          (self._svc_name_,''))
    self.main()

def main(self):
    self._proc = subprocess.Popen(self._cmd)
    self._proc.wait()

def killproc(self):
    self._proc.kill()

if name == 'main': win32serviceutil.HandleCommandLine(AppServerSvc) C:\Windows\Python27\python.exe kms-winservice.py install services.msc

Find "py-kms" service and change startup type from manual to auto. Try to start the py-kms service. Try activate Windows Server 2008 R2 VL: slmgr.vbs /skms 127.0.0.1 slmgr.vbs /ato

SystemRage commented 5 years ago

1) python3 pykms_Server.py -V INFO 2) https://github.com/SystemRage/py-kms/issues/23