Jump to content
1 post in this topic

Recommended Posts

Hi, I'm back again with another tool. As you may have seen in my thread, there is a Automator + AppleScript (thanks to @thanh) to make the reinstall/fix for UPDD, so I decided to make one application for everything with no hassle, however, since I'm not a programer, I'm just using AppleScript (for its fairly easy use and scripting).

I want you to help me out to fix (also optimize and clean) this script to make it better.

 

Here is the script:

-- Start with a welcome screen + password
set pwd to text returned of (display dialog ¬
	"Hello there
This is an AppleScript utility that will help you fix UPDD.
First I need your password to continue working of this:" with title ¬
	"UPDD Fix Script" with icon note ¬
	default answer ¬
	"" buttons {"Nope", "Continue ..."} ¬
	default button 2 cancel button 1 ¬
	with hidden answer)

-- Now show dialog for choice
set choice to (display dialog ¬
	"Hello there, what do you wanna do?" buttons {"Reinstall UPDD", "Start UPDD with time fix", "Exit"} ¬
	with title "What do you want to do?" cancel button 3)

-- Choice selection
if choice = {button returned:"Reinstall UPDD"} then
	-- Reinscall UPDD case
	display dialog ¬
		"Are you sure you want to reinstall UPDD?" buttons {"No", "Sure"} ¬
		default button 2 cancel button 1
	set sure_inst to button returned of result
	-- Starting the install
	-- TODO: If Nope is selected, loop back to the dialog of choices
	if sure_inst = "Sure" then
		-- Install UPDD
		-- TODO: Add a "Working..." window WHILE it's installing
		set install_result to do shell script "installer -pkg /Library/UPDD_*.pkg -target /" password pwd with administrator privileges
		-- Show Install results + updd fix prompt
		display dialog install_result with title "Install Results" buttons {"OK, now UPDD fix", "OK, I'm done here"} cancel button 2 default button 1
		-- UPDD Fix
		-- TODO: Same as the previous one
		tell application "UPDD Gestures" to quit saving no
		do shell script "/usr/sbin/systemsetup -setusingnetworktime off " password pwd with administrator privileges
		delay 2
		do shell script "/usr/sbin/systemsetup -setdate '04:05:15'" password pwd with administrator privileges
		delay 2
		tell application "UPDD Gestures"
			activate
		end tell
		delay 2
		-- ERROR: for some reason, it may give an error.
		do shell script "/usr/sbin/systemsetup -setdate '10:12:16' " password pwd with administrator privileges
		delay 2
		do shell script "/usr/sbin/systemsetup -setusingnetworktime on " password pwd with administrator privileges
		display notification "We're done." with title "We're all set."
	end if
	-- Done with UPPD Reinstall
	-- TODO: loop back to the choice menu
else if choice = {button returned:"Start UPDD with time fix"} then
	-- UPDD Fix
	display dialog ¬
		"This will bring back your maching clock back in 2015 then back to the actual internet time, this will momentally break some apps/connections (like synergy and maybe even some websites), make sure there are no active time-sensitive apps running if this can damage it or ruin your work" buttons {"Nope, stop", "OK, continue..."} default button 2 cancel button 1 with title "UPDD Rewind"
	set reupdd to button returned of result
	if reupdd = "OK, continue..." then
		-- TODO: Show a "Working..." window
		tell application "UPDD Gestures" to quit saving no
		do shell script "/usr/sbin/systemsetup -setusingnetworktime off " password pwd with administrator privileges
		delay 2
		do shell script "/usr/sbin/systemsetup -setdate '04:05:15'" password pwd with administrator privileges
		delay 2
		tell application "UPDD Gestures"
			activate
		end tell
		delay 2
		do shell script "/usr/sbin/systemsetup -setdate '10:12:16' " password pwd with administrator privileges
		delay 2
		do shell script "/usr/sbin/systemsetup -setusingnetworktime on " password pwd with administrator privileges
		display notification "We're done." with title "We're all set."
		-- TODO: loop back to the choice menu
	end if
end if
display dialog "Thank you for using this utility, please check insanleymac.com for more goodies!" buttons {"Thanks", "Get me to InsanelyMac"} with title "Thank you. We're done here." default button 1 cancel button 1
set done to button returned of result
if done = "Get me to InsanelyMac" then
	open location "http://www.insanelymac.com/forum/"
	delay 1
end if

Thanks for any help and feedback

  • Like 1
Link to comment
https://www.insanelymac.com/forum/topic/318405-tool-applescript-updd-tool/
Share on other sites

×
×
  • Create New...