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


  1. Posts : 7
    windows 10 64bit
       #1

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


    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


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hi there,

    joeykong said:
    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>COMPUTERNAME\Username</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


  3. Posts : 7
    windows 10 64bit
    Thread Starter
       #3

    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


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:18.
Find Us