閱讀878 返回首頁    go iPhone_iPad_Mac_apple


AppleScript Authentication Problem MacOS

Hello!

 

I have made a 'Troll' Application on AutoMator (MacOS Sierra) and will share it with my friends. At the end, I have it so that it asks the user to put their password in to stop the Application.

 

This is what I used:

 

on run

 

  set the current_user to (get the long user name of (system info)) as string

  set the input_password to the text returned of (display dialog "To Stop NOT_A_VIRUS.exe, Please enter the password for " & the current_user & ":" default answer "" buttons {"OK"} default button 1 with icon caution with hidden answer)

 

  try

 

  do shell script "history -c" user name the current_user password the input_password with administrator privileges

  on error

  display dialog "Wrong Password!" buttons {"Resume NOT_A_VIRUS.exe"} with icon caution

 

  end try

 

  set myProcesses to {"NOT_A_VIRUS"} -- The ones to quit.

 

  tell application "System Events"

  repeat with myProcess in myProcesses

  set theID to (unix id of processes whose name is myProcess)

  try

 

  do shell script "kill -9 " & theID

  end try

  end repeat

  end tell

  display dialog "Successfully Quitted NOT_A_VIRUS.exe" buttons {"OK"}

 

end run



When the user enters their password incorrectly, it says say "Wrong Password!" with a button that says "Resume NOT_A_VIRUS.exe"


When you press the button, it should only resume the App, but it also says Successfully Quitted NOT_A_VIRUS.exe.


Its kind of hard to explain, but if you do understand, please help.


-Regards

         13 Year Old Coder




最後更新:2017-09-23 17:31:36

  上一篇:go White screen after loading video app in IOS 11
  下一篇:go ios10 compatible with os4 ?