Windows – have to import .reg file from RegEdit in Win7 and not from .bat file

batch filewindowswindows 7windows-registry

I have a .bat file that makes a call to a .reg file (something like: regedit mytest.reg). I run the .bat file as administrator but I get an error: "Cannot import mytest.reg: Error opening the file. There may be a disk or file system error."

However, if I open RegEdit (as administrator) first then File >> Import >> mytest.reg … it successfully runs.

Any ideas?

Best Answer

Had the same problem. Once you accept running under elevated permissions, the "root" of the elevated session does not have the same relative location for the actual command.

If you specify an absolute address for the file it should work.

Now the $.42 question... what is the current directory for the elevated session in which the command is running?

Related Question