0

I am trying to run the following commands on start up for particular computers in a particular OU:

del "file_destination"  
REG ADD "registry_key" /v "value" /d "" /f 

I created a batch file with the above commands, but I do not know if the batch file can run with the Group Policy shutdown feature.

When I run the .bat file manually, the commands do not complete due to permissions, but if I run the batch file as an administrator it opens and closes automatically with no sign of completion.

I just need to remove the same file and replace the same registry key on multiple computers in my domain; it does not need to be a batch file. Please assist. Thank you!

BiigDogg
  • 1
  • 1
  • Dont know, why you need a sign of completion? – coo Nov 05 '14 at 11:28
  • When you say "no sign of completion," do you mean that the file isn't deleted and the registry key isn't added? Why don't you add a `pause` at the end of the script so that you can see any errors before the window goes away? – mojo Nov 05 '14 at 12:58
  • @mojo In one version of the file I do have two pause for both commands. When ran without [right click + Run as administrator] it runs pauses while telling me the commands cannot be completed due to permission. I do not need a sign of completion, but I have no sign of the batch file working when ran as administrator. But if I run the commands separately in an administrator command line they run flawlessly. Also, if there's a way to accomplish the file deletion and registry key value deletion in another way I am all ears. A batch file isn't necessary, just what I was working with. – BiigDogg Nov 06 '14 at 10:22
  • Running "as administrator" (an elevated prompt as your userid) is not the same as running as "Administrator" (the default privileged account). Is your user account in the local Administrators group? If not, running it "as administrator" (right-click, "Run as administrator") won't give the commands any higher privilege than your user account possesses. – mojo Nov 06 '14 at 13:10
  • @mojo My user account is not apart of the administrators group. Though I don't think that matters. If it did then why do my commands work when I open cmd.exe with "Run as administrator"? But if only open up cmd.exe with a single left click in the start menu, the commands will not complete due to lack of access or permission. Also keep in mind I want this to run at the system level for all the computers in my domain that need these files removed. – BiigDogg Nov 07 '14 at 07:41
  • It sounds like the batch file you have works fine so long as it's started in an elevated process. If you intend to run it as a GPO startup script, it should run as SYSTEM in an elevated process. – mojo Nov 07 '14 at 12:49
  • @mojo Thank you. I decided to make the script a shutdown script, so that when the Computers Power Up they will have created new files and values to replace the ones removed. I will be verifying if file and entry were created, there by verifying the scripts legitimacy. Both commands should work with the computer's elevated SYSTEM permissions. – BiigDogg Nov 09 '14 at 01:10

1 Answers1

0

Thank you @mojo for your consistent assistance.

The Batch script from the OP worked just fine.

I complicated the issue by trying to run the batch myself.

Probably due to security settings I could not get the batch itself to run as intended by right clicking and selecting "Run as Administrator".

But once I copied the file into the domain*\shutdown directory the script ran just fine.

BiigDogg
  • 1
  • 1