I have a simple batch file that copies three files to my \%windir%\syswow64 directory and then does a regsvr32 on these three files. The problem is, when I just run the batch file normally, it gives me an access denied error as Windows doesn't allow non-elevated copy commands to the syswow64 directory. So then, you would think that you could just right click on the batch file and say "run as administrator". The problem then is that when you run a batch file with elevated admin rights, it changes the current directory path for some reason and it can no longer find the files I am trying to copy! How do I fix this? Is there a way to reset the current directory in my batch file before it gets to the copy lines?
So just to clarify, I have a folder on the root (it could be anywhere) of my c:\ drive. In this folder is the batch file and the three files I want to copy. When I run the batch file as administrator, it changes the directory in the command prompt to c:\windows\system32 and it obviously cannot find the three files it needs to copy since they are not in the system32 folder to begin with.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.