You just don't have enough permission. It also depends on Windows version. On Windows 7 and later (Vista, too, but did it ever existed?
) with its UAC, it's not enough to be logged on as administrator, you still have to run the application under elevated privileges. Please see:
You can avoid exception in all cases, if you request elevated privileges from the very beginning, when you start the application in any way. You can embed appropriate application manifest with this option. Please see:
Note that you cannot avoid UAC dialog requesting for user confirmation, which would defeat the purpose of UAC. You can only switch off confirmation for the system globally, which I would not recommend.
See also: http://en.wikipedia.org/wiki/User_Account_Control