All Projects → iamacarpet → Go Win64api

iamacarpet / Go Win64api

Licence: mit
Windows API wrappers for Go - useful for SysOps

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Win64api

Notion Enhancer
an enhancer/customiser for the all-in-one productivity workspace notion.so (app)
Stars: ✭ 3,114 (+1565.24%)
Mutual labels:  windows-10
Codehub
A UWP GitHub Client
Stars: ✭ 162 (-13.37%)
Mutual labels:  windows-10
Win10 Secure Baseline Gpo
Windows 10 and Server 2016 Secure Baseline Group Policy
Stars: ✭ 170 (-9.09%)
Mutual labels:  windows-10
Chemo
Remove pre-installed junk from Windows 10.
Stars: ✭ 144 (-22.99%)
Mutual labels:  windows-10
Win10as
Make your windows 10 computer IOT friendly
Stars: ✭ 153 (-18.18%)
Mutual labels:  windows-10
Windowstemplatestudio
Windows Template Studio quickly builds a UWP app, using a wizard-based UI to turn your needs into a foundation of Windows 10 patterns and best practices.
Stars: ✭ 2,089 (+1017.11%)
Mutual labels:  windows-10
Wsl Proxy
WSL proxy files for editor/linux interop
Stars: ✭ 134 (-28.34%)
Mutual labels:  windows-10
Win10script
Win 10 Powershell Script to tweak and change windows settings
Stars: ✭ 184 (-1.6%)
Mutual labels:  windows-10
Compactgui
Visual Interface for the Windows 10 Compact Function
Stars: ✭ 2,103 (+1024.6%)
Mutual labels:  windows-10
Executivecallbackobjects
Research on Windows Kernel Executive Callback Objects
Stars: ✭ 169 (-9.63%)
Mutual labels:  windows-10
Ha4iot
Open Source Home Automation system for .NET
Stars: ✭ 146 (-21.93%)
Mutual labels:  windows-10
Euc Samples
Workspace ONE UEM (previously AirWatch) Samples and Guidance
Stars: ✭ 151 (-19.25%)
Mutual labels:  windows-10
Windows Auto Night Mode
Automatically switches between the dark and light theme of Windows 10 and Windows 11
Stars: ✭ 3,375 (+1704.81%)
Mutual labels:  windows-10
Kanban Tasker
A simple kanban board for Windows 10 Universal Windows Platform (UWP) written to manage tasks and create a simple and easy workflow for each board
Stars: ✭ 140 (-25.13%)
Mutual labels:  windows-10
Win32 Darkmode
Example application shows how to use undocumented dark mode API introduced in Windows 10 1809.
Stars: ✭ 176 (-5.88%)
Mutual labels:  windows-10
Offlineinsiderenroll
OfflineInsiderEnroll - A script to enable access to the Windows Insider Program on machines not signed in with Microsoft Account
Stars: ✭ 137 (-26.74%)
Mutual labels:  windows-10
Windows 10 Dark
Dark variant of Windows 10 theme
Stars: ✭ 163 (-12.83%)
Mutual labels:  windows-10
Win10clean
Cleanup your Windows 10 environment
Stars: ✭ 187 (+0%)
Mutual labels:  windows-10
Wslinstall
Install any GNU/Linux userspace in WSL
Stars: ✭ 178 (-4.81%)
Mutual labels:  windows-10
Puremvc Csharp Multicore Framework
PureMVC MultiCore Framework for C#
Stars: ✭ 166 (-11.23%)
Mutual labels:  windows-10

GoLang Windows API Wrappers

For System Info / User Management.

For an internal project, this is a set of wrappers for snippets of the Windows API.

Tested and developed for Windows 10 x64.

All functions that return useful data, do so in the form of JSON exportable structs.

These structs are available in the shared library, "github.com/iamacarpet/go-win64api/shared"

Process List

package main

import (
    "fmt"
    wapi "github.com/iamacarpet/go-win64api"
)

func main(){
    pr, err := wapi.ProcessList()
    if err != nil {
        fmt.Printf("Error fetching process list... %s\r\n", err.Error())
    }
    for _, p := range pr {
        fmt.Printf("%8d - %-30s - %-30s - %s\r\n", p.Pid, p.Username, p.Executable, p.Fullpath)
    }
}

Active Session List (Logged in users + Run-As users)

package main

import (
    "fmt"
    wapi "github.com/iamacarpet/go-win64api"
)

func main(){
    // This check runs best as NT AUTHORITY\SYSTEM
    //
    // Running as a normal or even elevated user,
    // we can't properly detect who is an admin or not.
    //
    // This is because we require TOKEN_DUPLICATE permission,
    // which we don't seem to have otherwise (Win10).
    users, err := wapi.ListLoggedInUsers()
    if err != nil {
        fmt.Printf("Error fetching user session list.\r\n")
        return
    }

    fmt.Printf("Users currently logged in (Admin check doesn't work for AD Accounts):\r\n")
    for _, u := range users {
        fmt.Printf("\t%-50s - Local User: %-5t - Local Admin: %t\r\n", u.FullUser(), u.LocalUser, u.LocalAdmin)
    }
}

Installed Software List

package main

import (
    "fmt"
    wapi "github.com/iamacarpet/go-win64api"
)

func main(){
    sw, err := wapi.InstalledSoftwareList()
    if err != nil {
        fmt.Printf("%s\r\n", err.Error())
    }

    for _, s := range sw {
        fmt.Printf("%-100s - %s - %s\r\n", s.Name(), s.Architecture(), s.Version())
    }
}

Windows Update Status

package main

import (
        "fmt"
        "time"
        wapi "github.com/iamacarpet/go-win64api"
)

func main() {
        ret, err := wapi.UpdatesPending()
        if err != nil {
                fmt.Printf("Error fetching data... %s\r\n", err.Error())
        }

        fmt.Printf("Number of Updates Available: %d\n", ret.NumUpdates)
        fmt.Printf("Updates Pending:             %t\n\n", ret.UpdatesReq)
        fmt.Printf("%25s | %25s | %s\n", "EVENT DATE", "STATUS", "UPDATE NAME")
        for _, v := range ret.UpdateHistory {
                fmt.Printf("%25s | %25s | %s\n", v.EventDate.Format(time.RFC822), v.Status, v.UpdateName)
        }
}

Local Service Management

List Services

package main

import (
    "fmt"

    wapi "github.com/iamacarpet/go-win64api"
)

func main(){
    svc, err := wapi.GetServices()
    if err != nil {
        fmt.Printf("%s\r\n", err.Error())
    }

    for _, v := range svc {
        fmt.Printf("%-50s - %-75s - Status: %-20s - Accept Stop: %-5t, Running Pid: %d\r\n", v.SCName, v.DisplayName, v.StatusText, v.AcceptStop, v.RunningPid)
    }
}

Start Service

err := wapi.StartService(service_name)

Stop Service

err := wapi.StopService(service_name)

Local User Management

List Local Users

package main

import (
    "fmt"
    "time"
    wapi "github.com/iamacarpet/go-win64api"
)

func main(){
    users, err := wapi.ListLocalUsers()
    if err != nil {
        fmt.Printf("Error fetching user list, %s.\r\n", err.Error())
        return
    }

    for _, u := range users {
        fmt.Printf("%s (%s)\r\n", u.Username, u.FullName)
        fmt.Printf("\tIs Enabled:                   %t\r\n", u.IsEnabled)
        fmt.Printf("\tIs Locked:                    %t\r\n", u.IsLocked)
        fmt.Printf("\tIs Admin:                     %t\r\n", u.IsAdmin)
        fmt.Printf("\tPassword Never Expires:       %t\r\n", u.PasswordNeverExpires)
        fmt.Printf("\tUser can't change password:   %t\r\n", u.NoChangePassword)
        fmt.Printf("\tPassword Age:                 %.0f days\r\n", (u.PasswordAge.Hours()/24))
        fmt.Printf("\tLast Logon Time:              %s\r\n", u.LastLogon.Format(time.RFC850))
        fmt.Printf("\tBad Password Count:           %d\r\n", u.BadPasswordCount)
        fmt.Printf("\tNumber Of Logons:             %d\r\n", u.NumberOfLogons)
    }
}

Adding a Local User

ok, err := wapi.UserAdd(username, fullname, password)

Deleting a Local User

ok, err := wapi.UserDelete(username)

Set Full Name Attribute

ok, err := wapi.UserUpdateFullname(username, fullname)

Give Admin Privileges

ok, err := wapi.SetAdmin(username)

Revoke Admin Privileges

ok, err := wapi.RevokeAdmin(username)

Disable/Enable User

s := true   // disable user
s := false  // enable user
ok, err := wapi.UserDisabled(username, s)

Change Attribute - User Can't Change Password

s := true   // User can't change password
s := false  // User can change password
ok, err := wapi.UserDisablePasswordChange(username, s)

Change Attribute - Password Never Expires

s := true   // Password never expires.
s := false  // Enable password expiry.
ok, err := wapi.UserPasswordNoExpires(username, s)

Forced Password Change

ok, err := wapi.ChangePassword(username, newpassword)

Windows Firewall - Add Inbound Rule

added, err := wapi.FirewallRuleCreate(
	"App Rule Name",
	"App Rule Long Description.",
	"My Rule Group",
	"%systemDrive%\\path\\to\\my.exe",
	"port number as string",
	wapi.NET_FW_IP_PROTOCOL_TCP,
)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].