2017-09-10 5 views
-1

私はこのアプリケーションが最後に使用されたときにアプリケーションを起動し、ポップアップでユーザーを表示するスクリプトをPowerShellに書き込もうとしています。まあ、私は働いている簡単なコマンドを使用してアプリケーションを起動するために、私はそれが長期的には効率的かどうか分からない:特定のアプリが使用されたときにPowershellでどのように判断するのですか?

start 'C:\Riot Games\League of Legends\LeagueClient.exe' 

、それはアプリケーションを開始した後、ポップアップが教えてください私が最後にアプリケーションを開始したのはいつですか?それは今私の目標です。

答えて

2

あなたはthis link

に行くことができますWscript.Shellオブジェクトの詳細情報を取得するには

start 'C:\Riot Games\League of Legends\LeagueClient.exe' 

を使用してプログラムを開くなどポップアップを取得...

#First you want to set your variable for the date and time 
#Get-ItemProperty is self explanatoy 
#select-object gets the LastAccesTime property and -expand isolates that property in a string versus a table 
$lastusetime = Get-ItemProperty "C:\Riot Games\League of Legends\LeagueClient.exe" | select-object -expandproperty LastAccessTime 

#set the com object for a window and give it a variable 
$wshell = New-Object -ComObject Wscript.Shell 

#use that variable and the "Pop Up" property of windows shell to set the Windows details. VOID disables any outputs in the powershell window 
[void]$wshell.Popup("Last Open $Lastusetime",0,"Program Details",0x1) 

ができ

これを行うには他の方法があるかもしれませんが、これが私のやり方です。

関連する問題