2012年12月21日 星期五

NET USE


 Protected Sub ropen()
        Dim processInfo As New System.Diagnostics.ProcessStartInfo()
        processInfo.FileName = "C:\WINDOWS\system32\net"
        processInfo.Arguments = "use \\xxx.xxx.x.xx /user:username key"
        System.Diagnostics.Process.Start(processInfo)
    End Sub


    Protected Sub rclose()
        Dim processInfo As New System.Diagnostics.ProcessStartInfo()
        ProcessInfo.FileName = "C:\WINDOWS\system32\net"
        processInfo.Arguments = "use \\1xxx.xxx.x.xx /DELETE"
        System.Diagnostics.Process.Start(processInfo)
    End Sub



*net user 查看使用者清單

  *net user 使用者名 密碼 /add 添加使用者

  *net user 使用者名 密碼 更改使用者密碼

  *net localgroup administrators 使用者名 /add 添加使用者到管理組

  *net user 使用者名 /delete 刪除使用者

  *net user 使用者名 查看使用者的基本情況

  *net user 使用者名 /active:no 禁用該使用者

  *net user 使用者名 /active:yes 啟用該使用者

  *net share 查看電腦IPC$共用資源

  *net share 共用名稱 查看該共用的情況

  *net share 共用名稱=路徑 設置共用。例如 net share c$=c:

  *net share 共用名稱 /delete 刪除IPC$共用

  *net use 查看IPC$連接情況

  *net use //ip/ipc$Content$nbsp;"密碼" /user:"使用者名" ipc$連接

  *net time //ip 查看遠端電腦上的時間

  *copy 路徑:/檔案名 //ip/共用名稱 複製檔到已經ipc$連接的電腦上

  *net view ip 查看電腦上的共用資源

  *ftp 伺服器位址 進入FTP伺服器

  *at 查看自己電腦上的計畫作業

  *at //ip 查看遠端電腦上的計畫作業

  *at //ip 時間 命令(注意加盤符) 在遠端電腦上加一個作業

  *at //ip 計畫作業ID /delete 刪除遠端電腦上的一個計畫作業

  *at //ip all /delete 刪除遠端電腦上的全部計畫作業

標籤:

2012年12月20日 星期四

上傳檔案


轉貼至ASP.NET 如何上傳檔案至遠端機器上

RemoteCopy.aspx.vb
Imports System.Web.Security
Imports System.Security.Principal
Imports System.Runtime.InteropServices
Partial Class RemoteCopy
    Inherits System.Web.UI.Page
    Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
    Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
    Dim impersonationContext As WindowsImpersonationContext
    Declare Function LogonUserA Lib "advapi32.dll" (ByVal lpszUsername As String, _
                        ByVal lpszDomain As String, _
                        ByVal lpszPassword As String, _
                        ByVal dwLogonType As Integer, _
                        ByVal dwLogonProvider As Integer, _
                        ByRef phToken As IntPtr) As Integer
    Declare Auto Function DuplicateToken Lib "advapi32.dll" ( _
                        ByVal ExistingTokenHandle As IntPtr, _
                        ByVal ImpersonationLevel As Integer, _
                        ByRef DuplicateTokenHandle As IntPtr) As Integer
    Declare Auto Function RevertToSelf Lib "advapi32.dll" () As Long
    Declare Auto Function CloseHandle Lib "kernel32.dll" (ByVal handle As IntPtr) As Long
    Private Function impersonateValidUser(ByVal userName As String, ByVal domain As String, ByVal password As String) As Boolean
        Dim tempWindowsIdentity As WindowsIdentity
        Dim token As IntPtr = IntPtr.Zero
        Dim tokenDuplicate As IntPtr = IntPtr.Zero
        impersonateValidUser = False
        If RevertToSelf() Then
            If LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
                If DuplicateToken(token, 2, tokenDuplicate) <> 0 Then
                    tempWindowsIdentity = New WindowsIdentity(tokenDuplicate)
                    impersonationContext = tempWindowsIdentity.Impersonate()
                    If Not impersonationContext Is Nothing Then
                        impersonateValidUser = True
                    End If
                End If
            End If
        End If
        If Not tokenDuplicate.Equals(IntPtr.Zero) Then
            CloseHandle(tokenDuplicate)
        End If
        If Not token.Equals(IntPtr.Zero) Then
            CloseHandle(token)
        End If
    End Function
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As SystemEventArgs) Handles Button1.Click
       If impersonateValidUser("userName", "xx.xx.xx.xx", "password") Then
            FileUpload1.SaveAs(
\\xx.xx.xx.xx\test\XX.TXT)
        End If

    End Sub
End Class

標籤: