Categorygithub.com/nyaosorg/go-windows-netresource
modulepackage
0.1.0
Repository: https://github.com/nyaosorg/go-windows-netresource.git
Documentation: pkg.go.dev

# README

go-windows-netresource

net use

// +build run

package main

import (
    "os"
    "os/exec"

    "github.com/nyaosorg/go-windows-netresource"
)

func main() {
    cancel, err := netresource.NetUse(`X:`, `\\localhost\C$`)
    if err != nil {
        println(err.Error())
        return
    }
    defer cancel(true, false)

    cmd := exec.Command("cmd.exe", "/c", "dir", `X:\`)
    cmd.Stdout = os.Stdout
    cmd.Stderr = os.Stderr
    cmd.Stdin = os.Stdin
    cmd.Run()
}

Find file servers and their shared folders

package main

import (
    "github.com/nyaosorg/go-windows-netresource"
)

func main() {
    machines := []string{}

    err := netresource.EnumFileServer(func(node *netresource.NetResource) bool {
        machines = append(machines, node.RemoteName())
        return true
    })
    if err != nil {
        println(err.Error())
    }

    for _, name := range machines {
        println("machine:", name)
        if fs, err := netresource.NewFileServer(name); err == nil {
            fs.Enum(func(node *netresource.NetResource) bool {
                println("  ", node.RemoteName())
                return true
            })
        }
    }

    if err != nil {
        println(err.Error())
    }
}

# Packages

No description provided by the author

# Functions

EnumFileServer lists up file-servers.
FindVacantDrive returns the last unused drive like 'Z'.
GetDiskFreeSpace retunrs disk information.
No description provided by the author
No description provided by the author
NetUse do same thing as `net use X: \\server\path...` drive - `X:` vol - `server\\path\...` returns func(update,force) - function release the drive update - true: updates connection as not a persistent one force - true: disconnect even if open process exists.
NewFileServer is constructor of NetResource for FileServer's root node.
UNCtoNetDrive replace UNCPath to path using netdrive.
No description provided by the author
WNetAddConnection2 makes a connection to a network resource and can redirect a local device to the network resource remote - UNC-Path like `\\localhost\C$` local - local-drive like `X:` user - username.
WNetCancelConnection2 cancels an existing network connection.
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
Code generated by go-importconst DO NOT EDIT.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
NetResourceHandle is compatible type with "net/http".File.