Jump to content
heinst

Getting Admin Password through Dialog

Recommended Posts


tell application "System Events"
	set theText to name of current user
end tell
display dialog theText default answer "" with hidden answer
set the adminpass to the text returned of the result

tell application "Finder"
	set iconPath to (get name of startup disk) & ":Applications:Utilities:Boot Camp Assistant.app:Contents:Resources:DA.icns" as alias
end tell

do shell script "bless -mount /Volumes/BOOTCAMP/ -legacy -setBoot -nextonly; shutdown -r now" password adminpass with administrator privileges

I have this applescript that restarts into windows and prompts for admin password before it does so. I can't figure out why it works in the applescript editor perfectly fine, but when run through alfred it doesnt prompt for the password or run at all....thoughts?

Share this post


Link to post

tell application "System Events"
	set theText to name of current user
end tell
display dialog theText default answer "" with hidden answer
set the adminpass to the text returned of the result

tell application "Finder"
	set iconPath to (get name of startup disk) & ":Applications:Utilities:Boot Camp Assistant.app:Contents:Resources:DA.icns" as alias
end tell

do shell script "bless -mount /Volumes/BOOTCAMP/ -legacy -setBoot -nextonly; shutdown -r now" password adminpass with administrator privileges

I have this applescript that restarts into windows and prompts for admin password before it does so. I can't figure out why it works in the applescript editor perfectly fine, but when run through alfred it doesnt prompt for the password or run at all....thoughts?

 

Just let AppleScript ask for the password. If you just use 'with administrator privileges' it should work fine.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...