0
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.
So you are saying you didn't set it to run under the system account but are expecting it to run under the system account just because the trigger you have set? – Squashman – 2017-11-17T17:17:13.913
1Are you sure you're supposed to be outputting to a file called
null
– None – 2017-11-17T17:28:54.873Yes. How should I specify it to run under the system account otherwise. Id like to say I'm not a expert at any of this. I can stumble through a lot, but there isn't a whole lot of waltzing going on here. Also, no I don't need it to output a null file. I was trying to suppress it writing a confirmation message in the cmd window. – None – 2017-11-17T18:09:29.823
On the General Tab of the task, Click the radio button to run whether user is logged on or not. Click Changer User or Group. Type in system. click Check Names. Click Ok. Click ok. – Squashman – 2017-11-17T18:20:29.190
1In Windows the null device is expressed as
NUL
. Just one L. – Squashman – 2017-11-17T18:21:41.833Alright, I haven't had a chance to try the above suggestion, but when running the script locally on a windows 7 machine it executes fine. However, when I run it on my new Laptop which is running Windows 10 it gives me access denied. All permissions concerning the Local Admin group are the same on both platforms and I cant figure out why this is. This is just a side note however. – None – 2017-11-17T19:56:39.167
@LaneDutch, then this really isn't a coding problem, which is what StackOverFlow is dedicated to. In General your original question isn't a coding problem. You may want to post your question on a different Stack Exchange site. – Squashman – 2017-11-17T20:03:20.257
Oh that was just a question until I get a second to edit the task. No worries. The above suggestion worked. Ill mark it as the answer. – None – 2017-11-17T20:07:07.793
Post your comment as a answer and Ill mark it for you. Thanks for the help. I apologize if it skirted the lines of what this forum is for, but I wasn't sure if there was a coding solution or not. – None – 2017-11-17T20:13:53.220
An AD start-up script rather than login script will run as system. – HelpingHand – 2017-11-17T23:46:28.603
Check here too: https://superuser.com/questions/1214736/windows-10-scheduled-tasks-with-workstation-lock-unlock-not-being-triggered/1217125#1217125
– Pimp Juice IT – 2017-11-18T05:04:54.157