I think that your question is a bit too general ("How to write lines of code to manipulate the windows interface?")
Here are solutions for tasks you have already mentioned:
To start/stop services you can use commands NET START/ NET STOP
net start / net stop / net pause / net continue
To unload (kill) processes you command
Taskkill
The interesting one would be Aero. I propose the following solution:
Save your aero theme, if you are not using default one.
To switch off aero use classic theme, just execute this line:
Code:
%windir%\Resources\Ease of Access Themes\classic.theme
To switch aero on execute your theme
Code:
%USERPROFILE%\AppData\Local\Microsoft\Windows\Themes\YOURsavedTHEME.theme
Or default aero one
Code:
%windir%\Resources\Themes\aero.theme
If problem with spaces in names of folders will occur use DOS links:
C:\progra~1 insread
C:\Program Files\
Basically, leave first 6 letters then put ~ and ordinal number of the file/folder name.
Ex.
C:\Program Files\ would be
C:\progra~1
but
C:\ProgramData would be
C:\progra~2