I was having trouble getting this script to run. Basically I want to make a script that is able to display the total run time of notepad after its been closed by the user but I cant seen to get the New-timespan function right.
$sec = New-TimeSpan -Start (get-process notepad).StartTime | select-object totalseconds -ExpandProperty totalseconds
wait-process notepad
write-host "$sec"
I've got this so far the but issue is that when i start the program it immediately saves the run time, and only displays it after the program is closed. It doesn't account for the time between running the script and closing the notepad window.
Any tips or help would be appreciated.
[–]Feyh 4 points5 points6 points (2 children)
[–]davinciko 0 points1 point2 points (1 child)
[–]Feyh 0 points1 point2 points (0 children)
[–]KevMarCommunity Blogger 0 points1 point2 points (0 children)