Search This Blog

Wednesday, May 4, 2016

How to convert Python script file to Executable (.exe) file

1) Create a setup.py file and put in the same directory as of the .py file you want to convert.

2)Copy paste the following lines in the setup.py and do change the "filename.py" into the filename you specified.

from cx_Freeze import setup, Executable
setup(
    name="GUI PROGRAM",
    version="0.1",
    description="MyEXE",
    executables=[Executable("filename.py", base="Win32GUI")],
    )
3) Run the setup.py "$python setup.py build"

4)A new directory will be there there called "build". Inside it you will get your .exe file to be ready to launced directly. (Make sure you copy paste the images files and other external files into the build directory)

Tuesday, May 3, 2016

Possible Security Breach error when you try to access your netlogon folder or any shared folder? Below is the registry fix. Apply the registry and restart the computer

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters
Dword MaxTokenSize
Value : 48000


Auto Elevate DotNet Applications

Below code will check if the dotnet application is started as administartor. if not then it will auto elevate the application

processinfo = New ProcessStartInfo(Assembly.GetEntryAssembly().CodeBase)
            processinfo.UseShellExecute = True
            processinfo.Verb = "runas"
            Process.Start(processinfo)
            Application.Exit()

Get LogonServer - VBscript

Function GetLogonServer()
 On Error Resume Next
 Dim strComputerDom, objWMIService, colItemsDom, objitemDom, strGetDomain
 strComputerDom = "."
 strGetDomain = "Domain: " & GetDomain
 Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerDom &  "\root\cimv2")
 Set colItemsDom = objWMIService.ExecQuery("Select Name,DomainName,DomainControllerName from  Win32_NTDomain Where Name='" & strGetDomain & "' ")
 For Each objitemDom In colItemsDom
   GetLogonServer = objitemDom.DomainControllerName
 Exit For
 Next

End Function

Above vbscript gets the Logon Server name. This is tested and confirm to work fine