-1

When I try to execute this command:

REG IMPORT myreg.reg

I get access denied message, because I'm not administrator. However I don't want to open command line using run as administrator in visual way.

How do I just execute this command in a bat file?

1

1 Answer 1

0

Try using runas

runas /savecred /user:administrator "YourBatchFile.bat"

where your batch file contains the commands you want to execute in the elevated command prompt. In your case that would be

REG IMPORT myreg.reg

You will still be prompted for administrator password, but only once. After you have successfully authenticated as admin, the credentials will be saved and you will not be prompted again until you change the admin password.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .