首頁 AutoIt Execute Software Use Admin
文章
Cancel

AutoIt Execute Software Use Admin

使用最高權限開啟指定檔案

詳見以下Source Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  #include <MsgBoxConstants.au3>
  #include <WinAPIFiles.au3>

  Example()

  Func Example()
      ; Create a constant variable in Local scope of the filepath that will be read/written to.
      Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

      Local $iFileExists = ("用來確認是否安裝完畢的檔案位置")
      Local $SetupFilePath ="安裝檔路徑"

      ; Display a message of whether the file exists or not.
      If  FileExists($iFileExists) Then
          MsgBox($MB_SYSTEMMODAL, "", "Teams已安裝")
     Else
	      If FileExists($SetupFilePath) Then
	         MsgBox($MB_SYSTEMMODAL, "", "安裝檔位置:存在");

		      If IsAdmin() Then
		         MsgBox($MB_SYSTEMMODAL, "", "如果是最高權限");
		         Run($SetupFilePath )
		      Else
		         MsgBox($MB_SYSTEMMODAL, "", "不是最高權限的安裝");
		         RunAs ("帳號","網域", "密碼",0,$SetupFilePath)
		      EndIf

	      Else
	         MsgBox($MB_SYSTEMMODAL, "", "安裝檔位置:不存在");
           EndIf

      EndIf

  EndFunc   ;==>Example

可以搭配的技術

本文由作者按照 CC BY 4.0 進行授權