抓取onceclick的發佈路徑的程式碼

            Dim strDirectoryName As String = ""
            Dim UserName() As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split("\")
            If UserName.Length > 1 Then
                strDirectoryName = "C:\Documents and Settings\" + UserName(1) + "\Local Settings\Apps\2.0\"
            Else
                strDirectoryName = "C:\Documents and Settings\" + UserName(0) + "\Local Settings\Apps\2.0\"
            End If
            Dim fs, f As Object
            Dim MaxFile As String = ""
            Dim update As Date

            For Each foundFile As String In My.Computer.FileSystem.GetFiles(strDirectoryName, FileIO.SearchOption.SearchAllSubDirectories, "POS_Stage.exe")

                fs = CreateObject("Scripting.FileSystemObject")
                f = fs.GetFile(foundFile)

                If Date.Compare(f.DateLastModified(), update) > 0 Then
                    update = f.DateLastModified()
                    MaxFile = foundFile
                End If
            Next
            If Application.ExecutablePath.ToString() <> MaxFile.ToString() Then
                Shell(MaxFile.ToString())
                Application.Exit()
                Application.ExitThread()

            End If

文章標籤
創作者介紹
創作者 王小雀 的頭像
王小雀

黃臉婆--冠上夫姓了 哈

王小雀 發表在 痞客邦 留言(0) 人氣()