1

Okay, here is the scenario. We are making some network changes where I work and would otherwise have to touch each PC to do this. I created a batch file with the code below. Obviously with our dns settings and admin password inserted.

@echo off

>nul wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder     ("DNS1", "DNS2")


>nul net user Administrator NEWADMINPASSWORD


2>nul net localgroup administrators /delete "Domain Users" 

The batch file runs just fine from both the local C: directory and the network location it is stored on, but when running as a task it fails. It was my understanding that when running a script at login it runs under the system account and thus shouldn't get denied access.

Any help would be greatly appreciated. Thanks.

jwdonahue
  • 123
  • 4

2 Answers2

1

Run Batch with the highest privileges under system account using Task Scheduler.

  1. Open Task Scheduler
  2. goto your task properties which runs the batch file
  3. Select General Tab
  4. Make sure your task settings are these...

    Uncheck Run only when user is logged on

    Check Run whether user is logged on or not

    Check Run with the highest privileges

This will ensure that the task will run as an account that has explicit "Full access" permissions to the system with highest privileges.

Click Here - ServerFault Solution

Gourav
  • 11
  • 1
0

Ended up running it in the logon script. Still had a problem related to the fact that the script we were calling was stored on a network drive being mapped by the same logon script. Because of how fast it all ran, the X drive wasn’t being mapped before the script was being called. We used the UNC path instead and the script ran flawlessly.

Thanks.