Solved creating a batch script to create a scedualed task on multiple pc's

joeykong

New member
Local time
1:12 PM
Messages
7
so im an IT specialist at a big car dealer ship im not that good with scripting but what i want to do is when i go around to a computer i want to be able to put a flash drive in run a batch script that creates a folder on the C drive transfers a few files (xml and .bat ) to that folder then from that folder i want to run the batch script that will create a scheduled task to run ccleaner when the pc is in idle for 10 min
we have 600+ pc's some are on the domain some are off the domain with various user names/passwords and pc names also different os's (xp win 7 and some vista) some are 32 bit but most are 64 bit


ok so i made a scheduled task on my pc then exported the XML i put the files on a flash drive then i made a batch to copy the other batch scripts/xml's to a folder on the c drive (that part im having no issue with )only issue i have is when i try to run the batch to make the task on a different pc then the one i created it on i get a message saying "error: no mapping between account names and security ID's was done <17,8>:logon type
i plan on just popping in the flash drive and running these scripts as i go around doing the preventive maintenance or wile im on a pc to troubleshoot an issue


here are my scripts

this one is run off the flash drive and creates a folder on the c drive i have no issues with that but im posting it just as a reference

@echo off
REM Check if 32 or 64-bit OS
if "%Processor_Architecture%"=="" goto oscheck
if "%Processor_Architecture%"=="x86" goto x86
if "%Processor_Architecture%"=="AMD64" goto x64

:x64
mkdir c:\autocleaner
copy createtask64bit.bat c:\autocleaner\
copy createtask32bit.bat c:\autocleaner\
copy autoclean32bit.xml c:\autocleaner\
copy ccleaner64.xml c:\autocleaner\
echo Everything was copied to \autocleaner to be installed
eject
pause
exit



after that i go to the autocleaner folder on the c drive and then run the other script either the 32 bit or 64 bit depending on the pc
both scripts are the same only diffence is what xml file it points to


schtasks /create /tn "ccleaner64" /xml "c:\autocleaner\ccleaner64.xml"
PAUSE

any suggestions ? id also like to be able to do this from one of our network drives

i can also attach the scrips and xml files if needed

thank you
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
hp
OS
windows 10 64bit
CPU
4720 hq quad core
Memory
16gb ddr3l
Graphics Card(s)
intel HD graphics 4600
Hard Drives
1tb 5400rpm hybrid drive
Antivirus
bitdefender total security 2016
Browser
google chrome
Hi there,

only issue i have is when i try to run the batch to make the task on a different pc then the one i created it on i get a message saying "error: no mapping between account names and security ID's was done <17,8>:logon type
Is this the only issue?

It's not a problem with batch but with Task Scheduler. Before you can import a task that originated from another computer, data contained in the "UserId" element of the task xml has to be changed to match up with a user that exists on the machine you are importing the task to.

E.g.
Code:
  <Principals>
    <Principal id="Author">
      <UserId>[COLOR="Red"]COMPUTERNAME\Username[/COLOR]</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
The part in red must be changed to one of the users of the machine you are trying to importing this task to.
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
thank you but i found out on a different forum to change it to system then run as admin this worked perfect for me on 2 pc's iv tested it on so far
thank you very much for your reply tho
Principal id="Author">
<UserId>System</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
hp
OS
windows 10 64bit
CPU
4720 hq quad core
Memory
16gb ddr3l
Graphics Card(s)
intel HD graphics 4600
Hard Drives
1tb 5400rpm hybrid drive
Antivirus
bitdefender total security 2016
Browser
google chrome
Back
Top