抓取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
留言列表