Tag Archives: Apple

Install Windows 10 64 bit on iMac 7.1 Early 2007 or how to make your old Mac usefull again

As title says it I was given the task to resurrect an iMac and put it back in business! ūüôā
Unlike Microsoft, Apple are very picky on how you gonna use your computer and are unpleasantly pushy on dragging you to buy more of their stuff. Simply said as some of you may already know you can not use old, but quite descent hardware wise Mac with Apple’s latest OS due to firmware restrictions. Luckily you can still make some use of it with Windows or Linux.
The iMac in question had a faulty hard drive, which luckily was not too difficult to replace. But as usual the troubles came soon after! ūüôā
With a freshly burned DVD with Windows 10 x64 a thought I will be quickly in the game, but NO – got stuck with a black screen and a message to pick the boot type and irresponsive keyboard! It turns out though the computer is 64 bit architecture its EFI is 32 bit and you have no chance to boot it from Windows 10 installation media…
Thanks to good and clever people online help is available! I read this post, downloaded the exe file provided and it all went well!
As the steps I took are slightly different I wanted to have a note of it.
First of course you will need the Windows 10 x64 image file, which you can download from Microsoft. Under Windows 10 with right click on the file select “Mount”.
Just to make life organised create a folder with a name of your choice, in my case it was “NewISO”.
Run Command Prompt as administrator and navigate to where you have the OSCDIMG.EXE file saved /or just type the full path to it/.
Then run the command:
oscdimg -n -m -bf:\boot\etfsboot.com f:\ c:\NewISO\win10_efi32.iso
where f is the drive letter where the image file is mounted.
After this you will have e 64 bit Windows 10 image file with 32 bit EFI, do not worry about the warning message related to NT 3.5, just burn it on DVD or USB stick and use it.
Final words – I do not quite know how this program, which is a Microsoft genuine tool, manages to change the boot loader. I would advice you to download it from the post link above or at least make sure you use the same version, which is 2.54, as this may have something to do with the success of the procedure and a newer one may just put back 64 bit EFI again. I will be glad if someone more knowledgeable explains it in detail.

ApleScript examples for Mac OS X El Capitan

Time is tight as usual, so let‚Äôs not waste it and get on with the already delayed El Capitan post. ūüôā

As some of you already know Apple introduced a new security feature to their latest OS X called System Integrity Protection (SIP). What it basically does is to limit access to sensitive parts of the OS, prevent code injection, etc. This is all fine probably for most users, but limits the possibilities of tweaking the system as well as flexibility of manipulating certain aspects of the OS’s behaviour.

So this brings some inconvenience when you try to automate certain aspects of your daily routine. For example the bless command will not work, you can no longer ‚Äúempty trash‚ÄĚ while a file is still engaged in a process, if disable SIP you can no longer do repair permissions on your system files as this feature has been removed from Disk Utility.

Simply said ‚Äď if you want the full control over the OS you will have to disable SIP. I am not going in to details on how to do it, there are many articles on internet about that. Here are just few links if you are interested:

Apple’s official article Рhttps://developer.apple.com/library/mac/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html

 

XtraFinder’s article on how to partially disable SIP Рhttps://www.trankynam.com/xtrafinder/sip.html

or this one for some more customisation – https://www.reddit.com/r/osx/comments/3hv3kk/update_on_rootless_the_configuration_mechanism/

 

Below you will find two AppleScripts, one for automating the process of repairing file permissions and the other one is for empting your trash.

First the script which does the permission repair. Before using it you will need to download and install the utility from here https://www.firewolf.science/2015/07/repairpermissions-v2-0-cli/

Make sure you follow the installation guidance, read the notes section ‚Äď it is kind of important.

Alternatively if you do not want to use this utility you may prefer to do it differently by using repair_packages command following this tutorial: http://lifehacker.com/verify-and-repair-permissions-from-the-command-line-in-1741718667

 

And the script itself, change the necessary bits with your data or change it the way it suits you:

 

display dialog¬†“Repair Disk Permissions”¬†buttons¬†{“VolumeName 1”, “Volume Name 2”, “QUIT”}¬†default button¬†“QUIT”

if¬†button returned¬†of¬†result¬†= “QUIT”¬†then

     quit

else

     set diskVol to the button returned of the result as text

¬† ¬† ¬†tell¬†application¬†“Terminal”

          activate

¬† ¬† ¬† ¬† ¬† set¬†RP¬†to¬†do script¬†“sudo /usr/local/bin/RepairPermissions \”/Volumes/” & diskVol¬†& “\” “

          delay 1

¬† ¬† ¬† ¬† ¬† tell¬†application¬†“System Events”

¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†keystroke¬†“YourPassword” &¬†return

          end tell

          set mainID to id of front window

¬† ¬† ¬† ¬† ¬† close¬†(every¬†window¬†whose¬†id¬†‚Ȇ¬†mainID)

          repeat until busy of RP is false

               delay 1

          end repeat

     end tell

end if

delay 30

tell¬†application¬†“Terminal”¬†to¬†quit

 

The second script for empting the trash looks a bit bloated, but as AppleScript has no understanding of ‚Äúgo to‚ÄĚ statement /at least I could not find any referral to it, though for some reason this statement is considered a bad practise/ I had no choice but to leave it as it is. Any suggestions are welcome.

As per my previous post regarding AppleScript you will have to adjust some details in the script:

 

 

do shell script¬†“sudo nvram SystemAudioVolume=%80”¬†password¬†“YourPass”¬†with¬†administrator privileges

do shell script¬†“defaults write com.apple.loginwindow TALLogoutSavesState -bool false”¬†password¬†“YourPass”with¬†administrator privileges

set¬†trashcontents¬†to¬†quoted form¬†of¬†(do shell script¬†“ls ~/.Trash”)

if¬†trashcontents¬†= “”¬†then

¬† ¬† ¬†tell¬†application¬†“Finder”¬†to¬†activate

¬† ¬† ¬†tell¬†application¬†“System Events”

¬† ¬† ¬† ¬† ¬† tell¬†process¬†“Finder”

¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†click¬†menu item¬†13¬†of¬†menu¬†1¬†of¬†menu bar item¬†“Apple”¬†of¬†menu bar¬†1

          end tell

     end tell

    delay 5

¬† ¬† ¬†tell¬†application¬†“System Events”

¬† ¬† ¬† ¬† ¬† tell¬†process¬†“loginwindow”

               activate

               click button 2 of window 1

          end tell

     end tell

else

¬† ¬† ¬†do shell script¬†“sudo rm -rf ~/.Trash/*”¬†password¬†“YourPass”¬†with¬†administrator privileges

     delay 10

¬† ¬† ¬†tell¬†application¬†“Finder”¬†to¬†activate

¬† ¬† ¬†tell¬†application¬†“System Events”

¬† ¬† ¬† ¬† ¬† tell¬†process¬†“Finder”

¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬†click¬†menu item¬†13¬†of¬†menu¬†1¬†of¬†menu bar item¬†“Apple”¬†of¬†menu bar¬†1

          end tell

     end tell

     delay 5

¬† ¬† ¬†tell¬†application¬†“System Events”

¬† ¬† ¬† ¬† ¬† tell¬†process¬†“loginwindow”

               activate

               click button 2 of window 1

          end tell

     end tell

end if

 

And that‚Äôs it for now, hope this helps not just me, but someone else too ūüôā

 

 

 


Useful AppleScript examples

Here are some useful /I think/ AppleScript examples which can be used on their own or in other scripts. The presumption here is you already have an idea of how to use the Script Editor. Keep in mind some scripts might not behave as it should depending on your OS X and will need to be slightly adjusted. I will do separate post just for EL CAPITAN when I got some time. ūüôā

Ways to open and close applications with apple script:

If you want or need to use the Terminal to open an application:

 

tell application “Terminal”

¬†¬†¬†¬†¬† do script “open /Applications/Safari.app; exit”

end tell

delay 2

tell application “Terminal” to quit

 

But if you prefer the short way of doing it you can just type

 

do shell script “open /Applications/Safari.app; exit”

 

or

 

tell application “Safari” to activate

 

And to close application few options are as follows

 

tell application “Safari” to quit

 

or

 

do shell script “killall Safari”

 

Closing Finder application will simply reload it, which is sometimes necessary

 

do shell script “killall Finder” password “YourPassword” with administrator privileges

 

Managing optical drives:

When the case is to manage optical drives using applescript my personal opinion is this is best done with the use of drutil command. To find more about the command you can man it and in terminal window you can:

 

$ drutil info

 

As an example to close the tray of optical drive with the name ‚ÄúDVD-RW GH41N‚ÄĚ you can:

 

tell application “Terminal”

¬†¬†¬†¬†¬† do script “drutil tray close -drive ‘DVD-RW GH41N’; exit”

end tell

delay 3

tell application “Terminal” to quit

 

or if it is external one you can just

 

tell application “Terminal”

¬†¬†¬†¬†¬† do script “drutil tray close -drive external; exit”

end tell

delay 3

tell application “Terminal” to quit

 

To open the tray

 

tell application “Terminal”

¬†¬†¬†¬†¬† do script “drutil eject -drive ‘DVD-RW GH41N’; exit”

end tell

delay 3

tell application “Terminal” to quit

 

Automating shutdown and restart:

If the case is to shutdown or restart the computer with just a click of a button you can use the scripts below. They will also do some additional tasks like switching off the option of restarting the active application on boot, silence the startup chime, empty the trash can, which you may of course skip.

Reboot using terminal command:

 

do shell script “defaults write com.apple.loginwindow TALLogoutSavesState -bool false” password “YourPassword ” with administrator privileges

delay 2

do shell script “nvram SystemAudioVolume=%80” password “YourPassword ” with administrator privileges

delay 2

do shell script “shutdown -r now” password “YourPassword” with administrator privileges

 

Reboot using Mac OS X menu, mind though menu item 13 in the example might not be correct for you, so adjust it if necessary:

 

do shell script “defaults write com.apple.loginwindow TALLogoutSavesState -bool false” password “YourPassword” with administrator privileges

delay 2

do shell script “sudo nvram SystemAudioVolume=%80” password “YourPassword” with administrator privileges

delay 2

tell application “Finder” to activate

tell application “System Events”

¬†¬†¬†¬†¬† tell process “Finder”

¬†¬†¬†¬†¬†¬† click menu item 13 of menu 1 of menu bar item “Apple” of menu bar 1

      end tell

end tell

delay 3

tell application “System Events”

¬†¬†¬†¬†¬† tell process “loginwindow”

       activate

       click button 2 of window 1

      end tell

end tell

 

To shutdown the computer, following the same order and logic as above use the examples below. Again mind menu item 15, the number might not be the same for you.

 

tell application “Finder”

      empty trash with security

end tell

do shell script “shutdown -h now” password “YourPassword” with administrator privileges

 

or

 

tell application “Finder”

      empty trash with security

end tell

delay 10

tell application “Finder” to activate

tell application “System Events”

¬†¬†¬†¬†¬† tell process “Finder”

¬†¬†¬†¬†¬†¬† click menu item 15 of menu 1 of menu bar item “Apple” of menu bar 1

      end tell

end tell

delay 3

tell application “System Events”

¬†¬†¬†¬†¬† tell process “loginwindow”

       activate

       click checkbox 1 of window 1

       click button 2 of window 1

      end tell

end tell

 

Changing startup disk:

Something else which like me you can find useful is to quickly reboot to another Mac OS X installation. The first script is using script with buttons, which is faster, but Apple decided you do not need more then 3 buttons in a script dialog. So if you are having more than 3 bootable drives /some people do, trust me :-)/ you have to use a script with a list. Reboot.app in the examples is another script to reboot the computer, but you can do it differently.

The example script with the buttons:

 

display dialog “Select a startup disk” buttons {“NameOf HD1”, “NameOf HD2”, “QUIT”} default button “QUIT”

if button returned of result = “QUIT” then

      quit

else

      set bootVol to the button returned of the result as text

¬†¬†¬†¬†¬† do shell script “bless -mount \”/Volumes/” & bootVol & “\” -setBoot” password “YourPassword” with administrator privileges

¬†¬†¬†¬†¬† tell application “Reboot.app” to activate

end if

 

And for a list it might be something like this:

 

set Disks to {“1”, “2”, “3”, “4”, “5”}

set selectedDisk to {choose from list Disks with title “Startup Disk” with prompt “Choose Disk” default items “2” without multiple selections allowed and empty selection allowed}

do shell script “bless -mount \”/Volumes/” & selectedDisk & “\” -setBoot” password “YourPassword” with administrator privileges

tell application “Reboot.app” to activate

 

This is just an example script showing how to control an application with System Events, in this case Skype. Here the preferred web cam is picked from the list of available devices.

 

tell application “Skype” to activate

delay 5

tell application “System Events”

¬†¬†¬†¬†¬† tell process “Skype”

¬†¬†¬†¬†¬†¬† click menu item 3 of menu 1 of menu bar item “Skype” of menu bar 1

      end tell

end tell

delay 5

tell application “System Events”

¬†¬†¬†¬†¬† tell process “Skype”

       set winName to the name of window 1

¬†¬†¬†¬†¬†¬† if winName = “General” then

¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† click button “Audio/Video” of toolbar 1 of window 1

                   click pop up button 2 of window 1

¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† click menu item “FaceTime HD Camera (Display)” of menu 1 of pop up button 2 of window “Audio/Video”

       else

¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† tell application “System Events” to keystroke “w” using command down

       end if

      end tell

end tell

 

That is quite enough for now, future scripts will be in separate posts, hope you found this information useful. Enjoy ūüôā