Note that rooting may void your device warranty, So Try this at your own risk.
The following rooting method applicables for both unlocked and locked bootloaders. Refer this XDA thread to unlock and re-lock the bootloader of Sony Xperia Z.
- This rooting method is for Sony Xperia Z which comes with Jelly Bean Android version (10.1.D.0.317, 10.1.D.0.322, 10.1.A.1.350).You can check Android version by visiting Settings >> About the Phone
- You need to install ABD drivers on your Windows PC. Get the drivers from here.
- Windows 8 users follow this guide to change the settings before installing the drivers mentioned above.
- Download this rooting tool kit (1.9Mb)
Rootingfollow the steps sequentially
- You need to increase screen timeout to 10 mins : Settings >> Display >> Sleep >> 10 mins
- Enable USB Debugging mode : Settings >> Developer options >> Enable and Settings >> Developer options >> USB Debugging (check the option)
- Enable install from “unknown sources” option : Settings >> Security >> Unknown source (check the option)
- Save the rooting tool kit (.zip file) mentioned above in C drive (C:\) and Extract it there itself.
- Quit applications like PC Suite, PC Companion, Flashtool, etc. as they will interfere with the rooting process.
- Now Connect your phone to PC and run “runme.bat” file from the extracted folder (step 4)
- Wait for few seconds till you get the option “press the button to restore the data in your phone”
- Now do not down your Phone screen, it will start an App automatically and Select Restore data.
- You will see the message “if Restoring data is complete” in command prompt
- Now open your phone and dial this number *#*#7378423#*#*
- Select the option “Service tests” in your phone operation
- Now select the option “Display”. Now the screen will turn white and few commands will be executed automatically.
- Now press the power button to turn off screen, wait for few seconds and press it again (repeat it a few times) and keep observing the command prompt for outputs
- Finally you will see the messages like “transfer files to your phone part2“, “installing busybox,su,Superuser,etc…” & finally “Cleaning up“
- Now your phone will automatically restart.