コンピュータを共有資源に接続します。

'ネットワーク関連の処理を行います

Public NotInheritable Class Net

    'コンピュータを共有資源に接続します。
    Public Function Connect(ByVal networkpath, ByVal user, ByVal pass)

        Dim ShellCommand As String = "net use [networkpath] [pass]
/USER:[user]"
        ShellCommand = Replace(ShellCommand, "[networkpath]", networkpath)
        ShellCommand = Replace(ShellCommand, "[user]", user)
        ShellCommand = Replace(ShellCommand, "[pass]", pass)

        Return Shell(Pathname:=ShellCommand, Wait:=True, Timeout:=30000)

    End Function

    'コンピュータを共有資源から切断します。
    Public Function Disconnect(ByVal networkpath)

        Dim ShellCommand As String = "net use [networkpath] /DELETE"
        ShellCommand = Replace(ShellCommand, "[networkpath]", networkpath)

        Return Shell(Pathname:=ShellCommand, Wait:=True, Timeout:=30000)

    End Function
End Class