I have a small C# program to modify a xml file which is located under Program Files
. The machine is a Windows 7
machine. This small program is launched by a batch file (called A.bat
) because I want to pass a parameter to it.
I have a master batch file (called M.bat
) which is the start point. The M.bat
will start an installer and wait untile the installation finished. Then the M.bat
will start A.bat
which will launch my small program with a parameter.
Right now I get the following exception:
System.UnauthorizedAccessException: Access to the path 'C:\Program Files\MyTest\Test.config' is denied.
I know it is caused by tighter security in Win7. It works fine under XP.
I cannot use "Run as Administrator" to start M.bat
or manually "Run as Administrator" to start A.bat
because both will report cannot find the target executable (because the start location is not really the "current" location then).
Is there a way to start an executable as Administrator in batch file? or in C# program I can give myself Administrator right?
or ...