Jump to content

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?

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.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...