Client Management Suite

 View Only
  • 1.  Problem with random number in job script

    Posted Aug 08, 2016 06:27 AM

    Hello,

    i have following problem:

     

    I want to run a job on every server to change a specific setting from a scheduled windows task (an argument  in the execute command).

    This argument hast to be a random number between 1 and 30.  The code is the following:

    set /a num=%random% %%30
    
    schtasks /change /tn "NAME_OF_THE_TASK" /tr "c:\PATH_TO_CMD_FROM_TASK.cmd %num%"

    The script is working fine, but only on a single server. If i run that job on a number of servers, they all have the same random number in the windows task.

     

    Does anyone know how to fix this?

    Is it possible to configure a job, that handles every server after another?

     

    Greetings,

     



  • 2.  RE: Problem with random number in job script

    Posted Aug 08, 2016 11:52 AM

    The first thing I'd do is echo out the %num% to a file:

    set /a num=%random% %%30
    echo %num% > %temp%\num.txt
    schtasks /change /tn "NAME_OF_THE_TASK" /tr "c:\PATH_TO_CMD_FROM_TASK.cmd %num%"

     



  • 3.  RE: Problem with random number in job script

    Posted Aug 09, 2016 04:25 AM

    Yes, i did that already to check if the variable was set correct. the number in the file is equal to the argument of the task.

     

    Do you know if it's possible do change the job to execute sequentially every server step by step?



  • 4.  RE: Problem with random number in job script

    Posted Aug 09, 2016 11:01 AM

    I don't think there's any built in function that will let you run the script on a sequence of clients one at a time. You could put the Task into a Managed Software Delivery Policy and it will then run as the Agent on the client server requests configuration and picks up the Policy.