system_management_functions

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add_to_path added in v1.0.0

func Add_to_path(path_to_add string) error

Add_to_path adds the given path to the top of the system PATH (HKLM) if not already present. It broadcasts the environment change so apps like Explorer pick it up.

func Choco_install

func Choco_install(package_name string) error

Choco_install installs the given Chocolatey package and checks if it was installed successfully.

func Create_desktop_shortcut added in v1.1.0

func Create_desktop_shortcut(target_path, shortcut_name, description string, window_style int, all_users bool) error

Create_desktop_shortcut creates a .lnk shortcut on the desktop. It accepts the target path, shortcut name (optional), description (optional), window style (3 = maximized), and allUsers flag.

func Do_not_hide_search_box(restartExplorer bool) error

Do_not_hide_search_box sets SearchboxTaskbarMode = 2 to show the full search box on the taskbar. If restartExplorer is true, Explorer will be restarted to apply the change.

func Do_not_show_file_extensions added in v1.6.0

func Do_not_show_file_extensions(restartExplorer bool) error

Do_not_show_file_extensions sets HideFileExt = 1 to hide file extensions. If restartExplorer is true, Explorer is restarted to apply the change immediately.

func Do_not_show_hidden_files added in v1.7.0

func Do_not_show_hidden_files(restartExplorer bool) error

Do_not_show_hidden_files sets Hidden = 2 to hide hidden files in File Explorer. If restartExplorer is true, Explorer will be restarted to apply the change immediately.

func Download_file added in v0.9.0

func Download_file(destination_path string, url string) error

Download_file downloads a file from the given URL and saves it to the specified destination path.

Parameters:

  • destination_path: The full file path (including filename) where the downloaded content will be saved.
  • url: The HTTP or HTTPS URL from which to download the file.

Returns:

  • An error if the download, file creation, or writing fails; otherwise, nil.

Example:

err := Download_file("C:\\downloads\\example.exe", "https://example.com/file.exe")
if err != nil {
    log.Fatalf("Download failed: %v", err)
}

func Exclude_from_Microsoft_Windows_Defender added in v1.2.0

func Exclude_from_Microsoft_Windows_Defender(path_to_exclude string) error

Exclude_from_Microsoft_Windows_Defender excludes the given file or folder from Microsoft Defender.

If a file is given, its parent folder is excluded instead. This requires administrator privileges.

Parameters:

  • path_to_exclude: Absolute path to a file or folder to exclude.

Returns:

  • An error if exclusion fails; nil otherwise.

func Extract_password_protected_zip added in v1.3.0

func Extract_password_protected_zip(src, dest, password string) error

Extract_password_protected_zip extracts a password-protected ZIP archive using AES or ZipCrypto.

Parameters:

  • src: full path to the .zip archive
  • dest: directory where the files should be extracted
  • password: the password used to decrypt the archive

Returns:

  • error if extraction fails, otherwise nil

func Extract_zip added in v1.1.0

func Extract_zip(src, dest string) error

Extract_zip extracts a ZIP archive specified by src into the destination directory dest.

It protects against Zip Slip attacks by ensuring all extracted paths are within dest.

Parameters:

  • src: Full path to the ZIP archive.
  • dest: Destination directory where the contents will be extracted.

Returns:

  • An error if extraction fails, or nil on success.

func File_exists added in v0.7.2

func File_exists(path string) bool

File_exists checks if a file exists and is not a directory.

func Hide_search_box(restartExplorer bool) error

Hide_search_box sets SearchboxTaskbarMode = 0 to hide the taskbar search box. If restartExplorer is true, Explorer will be restarted to apply the change.

func Install_Java added in v0.7.0

func Install_Java() error

Install_Java ensures Java is installed by checking Is_Java_installed(). If not found, it installs the temurin21 JDK via Chocolatey. You could use Is java installed after choco_install(java). Install_Java ensures Java is installed by checking Is_Java_installed(). If not found, it installs the temurin21 JDK via Chocolatey and verifies the result.

func Install_choco added in v0.5.0

func Install_choco() error

Install_choco installs Chocolatey using the official PowerShell script. It takes no arguments and logs output to the standard logger. You could have Install_Choco check if choco is installed before installing. Then you could just call Install_Choco, and it would handle the details of whether Choco was installed or not. Install_choco installs Chocolatey if it is not already installed. It logs all steps to the standard logger.

func Is_Choco_installed added in v0.6.0

func Is_Choco_installed() bool

Is_Choco_installed checks if Chocolatey is installed. It returns true if choco.exe is found in PATH or at the default location.

func Is_Java_installed added in v0.7.0

func Is_Java_installed() bool

Is_Java_installed checks if both java.exe and javac.exe are available in PATH, or in the default Eclipse Adoptium installation directory.

func Remove_from_path added in v1.1.0

func Remove_from_path(path_to_remove string) error

Remove_from_path removes the given path from the system PATH if present. It normalizes the path, modifies HKLM registry, and broadcasts environment changes.

func Seconds_in_taskbar added in v1.9.0

func Seconds_in_taskbar(restartExplorer bool) error

Seconds_in_taskbar enables seconds on the taskbar clock by setting ShowSecondsInSystemClock = 1. If restartExplorer is true, Explorer will be restarted to apply the change.

func Set_dark_mode added in v1.4.0

func Set_dark_mode(restartExplorer bool) error

Set_dark_mode sets Windows to dark mode for both system and apps. If restartExplorer is true, it restarts Explorer to apply the change.

func Set_light_mode added in v1.4.0

func Set_light_mode(restartExplorer bool) error

Set_light_mode sets Windows to light mode for both system and apps. If restartExplorer is true, it restarts Explorer to apply the change.

func Set_start_menu_to_center added in v1.5.0

func Set_start_menu_to_center() error

Set_start_menu_to_center sets the Windows 11 taskbar alignment to the center by writing TaskbarAl=1 in the registry and restarting Explorer.

func Set_start_menu_to_left added in v1.5.0

func Set_start_menu_to_left() error

Set_start_menu_to_left sets the Windows 11 taskbar alignment to the left by writing TaskbarAl=0 in the registry and restarting Explorer.

func Show_file_extensions added in v1.6.0

func Show_file_extensions(restartExplorer bool) error

Show_file_extensions sets HideFileExt = 0 to make file extensions visible. If restartExplorer is true, Explorer is restarted to apply the change immediately.

func Show_hidden_files added in v1.7.0

func Show_hidden_files(restartExplorer bool) error

Show_hidden_files sets Hidden = 1 to show hidden files in File Explorer. If restartExplorer is true, Explorer will be restarted to apply the change immediately.

func Take_seconds_out_of_taskbar added in v1.9.0

func Take_seconds_out_of_taskbar(restartExplorer bool) error

Take_seconds_out_of_taskbar disables seconds on the taskbar clock by setting ShowSecondsInSystemClock = 0. If restartExplorer is true, Explorer will be restarted to apply the change.

func Winget_install added in v0.4.2

func Winget_install(package_name string, package_id string) error

Winget_install installs the specified package using winget with standard flags. Example: Winget_install("Visual Studio Code", "Microsoft.VisualStudioCode")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL