Reputation: 10571
I have the following code in the batch-file:
@echo on
regedit.exe /S abc.reg
If I run it, I get an error.
I searched the google for this and found nothing. Can someone help me please? I tried: - removing /S (the I can read (of course) the errormessage - Run the file as administrator (I'm admin per default)
I am using windows 8. The erros message: "Cannot import C:\users....abc.reg". Error opening the file. There may be a disk or a file system error.
Both Files are in the same folder.
Upvotes: 1
Views: 7581
Reputation: 7046
Right click on aix2_mm.bat and select "Run As Administrator", you will get a full screen UAC prompt that you must agree with, then it will work.
If you don't see 'Run As Administrator' as an option, hold the shift key prior to right clicking.
and it wouldn't hurt to make your batch more portable. The %~dp0 parameter will expand to the full path to ABC.reg if it's in the same folder as the .bat file.
@echo on
regedit.exe /S "%~dp0abc.reg"
Upvotes: 2
Reputation: 2033
Be careful the working directory
My bat file always has the code on first line
cd /d %~dp0
It can safely change current directory to your bat file directory
Upvotes: 1
Reputation: 10571
The problem was, that I handled the %~dp0 in a false way. %~dp0 stands for the default path, but you don't have to set a backslash after it!
If you want to run a .reg file in the same folder as the .bat file, just write it like this:
@echo on
REGEDIT /S "%~dp0ABC.reg"
This will run the file ABC.reg in the same folder.
If you wan't to run something in a subfolder, you have to do it like this:
@echo on
REGEDIT /S "%~dp0SUBFOLDER\ABC.reg"
The brackets ("") are only needed, if there are whitespaces in the pathname.
Upvotes: 3
Reputation: 8302
Much easier way is run it as a Scheduled task.
In this way you can get your batch file to run as admin without annoying password prompts.
For more valuable information, please read here...
http://forums.whirlpool.net.au/archive/2037875
http://www.myitforum.com/articles/1/view.asp?id=12036
Upvotes: 2