I had the same problem and figured out, that there seems to be a bug in the class QgsVectorFileWriter.writeAsVectorFormat
I was pretty sure that I had permission for the folder and in my case this did NOT work anyway:
although the folder 'test' existed on my desktop and had all rights.
Now the most absurd thing to try was to make "test" upper case --> "Test"
and now it worked! Further I tried to check the folders before the last folder where the file was to be saved in for case sensitivity and if I changed (in this code example) 'Desktop' to lower case ('desktop') it worked!
On the other hand something like
QgsVectorFileWriter.writeAsVectorFormat(temp_layer, "C:\Users\Myname\desktop\test1\test2\wasneues4.shp", "utf-8", None, "ESRI Shapefile") would NOT work, but
QgsVectorFileWriter.writeAsVectorFormat(temp_layer, "C:\Users\Myname\desktop\Test1\Test2\wasneues4.shp", "utf-8", None, "ESRI Shapefile") with both T's upper case works! Very weird...
Hopefully this was not driving too many people crazy ^^ I will report this bug.
My QGis Version: 2.8.2, so not the latest.