+ Reply to Thread
Page 2 of 2 First 12
Results 26 to 33 of 33
  1. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #26
    That's why it would be better just to use psexec to have it schedule a defrag on the machines than having it do the defrag on the machines.
    Reply With Quote Quote  

  2. SS -->
  3. Junior Member
    Join Date
    Jun 2008
    Location
    Fort Wayne, Indiana
    Posts
    8

    Certifications
    A+, N+, MCP, MCSA
    #27
    Setting up the scheduled task command I get prompted for a password for each machine as it does it. I set it up to test on 3 machines on the network to see the results.

    this is what I run:

    psexec @c:\PsTools\scheduletest.txt -u Administrator -p <password> schtasks /create /sc monthly /st 18:30:37 /tn "Monthly Defrag" /tr "C:\WINDOWS\SYSTEM32\defrag.exe"

    It then prompts me for the password:

    \\coll3:

    The task will be created under current logged-on user name ("COLL3\Administrator").
    Please enter the run as password for COLL3\Administrator: <password>
    SUCCESS: The scheduled task "Monthly Defrag" has successfully been created.
    schtasks exited on coll3 with error code 0.



    Then it moves to the next one...and prompts me again. I tried to add the -u and -p flags in the schedule task command right after the /create, but it says wrong syntax. So where would I specifiy that user/pass in order to avoid the request on 150 computers?

    One day at a time...heh...

    Chris
    Reply With Quote Quote  

  4. Junior Member
    Join Date
    Jul 2008
    Location
    texas
    Posts
    1

    Certifications
    MCP
    #28

    Default IF

    What about using a triggering syntax?

    For example, i want to scan my 100 or so machines, but if they do not require defragging, then skip to the next, but if it does require defragging, then initiate.

    Ive tried lots of IF and FOR's, but none seem to truly trigger the way i want. Ive also tried piping with some findstr "", but still running into syntax issues.
    Reply With Quote Quote  

  5. Junior Member
    Join Date
    Aug 2008
    Posts
    2
    #29

    Default Easy simultaneous defrag jobs

    I was trying to solve the same problem of defragging all machines on a network and found this thread. I liked what I saw in your solutions, so I thought I'd try to take it to the next level. Here is the batch file that I wrote trying to implement the best thoughts from this thread.


    I recommend leaving the comments in it. The file should be called defragSubnet.bat. It is recursive, so if you change the file name, you must also change the line of code where it calls itself.
    I wrote it according to my current needs, so it will only scan subnets starting with 192.168. and not others. Feel free to modify it as you need to. You'd just need to add a couple more arguments and variables.
    It would also be easy to change this to run any command on an entire network, provided that they all have the same administrative password.

    Script begins below this line.
    ---------------------------------------------------------------------
    echo off
    REM defragSubnet.bat
    REM This batch file takes the following arguments
    REM Subnet (192.168.XXX), Starting address (192.168.XXX.YYY), Ending address (192.168.XXX.ZZZ), Number of machines to scan per thread, and a 1
    REM this is a recursive program, so the last 1 just indicates that it was the parent of all the children it calls
    REM example: defragSubnet.bat 2 100 150 5 1
    REM this would defrag all machines from 192.168.2.100 - 192.168.2.150, in blocks of five (thus reducing the load on the machine calling the script)
    REM example: defragSubnet.bat 2 100 150 1 1
    REM this would defrag all machines from 192.168.2.100 - 192.168.2.150, in blocks of one (essentially doing all target machines simultaneously)
    REM Larger blocks mean longer time to completion; smaller blocks mean greater overhead on server calling this script
    REM for scheduled jobs, just make a second script that calls this one with your favorite settings

    SET /a subnet=%1
    SET /a i=%2
    SET /a final=%3
    SET /a numInstances=%4
    SET /a parent=%5


    IF %parent%==1 (GOTO callChildren) else (GOTO defrag)

    :callChildren
    IF %i% GEQ %final% GOTO END
    set /a block=%i%+%numInstances%
    START "" defragSubnet.bat %1 %i% %block% %4 0
    SET /a i=%block%
    GOTO callChildren


    :defrag
    IF %i%==%final% GOTO END
    ECHO 'psexec \\192.168.%subnet%.%i% defrag C:'
    psexec \\192.168.%subnet%.%i% defrag C:
    SET /a i=%i%+1
    GOTO defrag

    :end
    EXIT
    Reply With Quote Quote  

  6. Junior Member
    Join Date
    Aug 2008
    Posts
    2
    #30

    Default RE: Triggering Syntax

    Oh, and to answer wetpiggirl's question about only defragging as needed, I'm pretty sure that the standard defrag command does that. If you add -a it will only analyze and never defrag, and if you add -f it will force a defrag.

    [Edit] No, I was wrong. With the default settings, it appears to attempt a defrag even with 0% file fragmentation. [/Edit]
    Reply With Quote Quote  

  7. Senior Member theseman's Avatar
    Join Date
    Mar 2006
    Location
    Manitoba, Canada
    Posts
    230

    Certifications
    A+, Net+, MCSE 2k3
    #31
    You could install the GP client extensions on all of the PC's (WSUS) then use a Vista machine to setup the task.

    (Comp Config- Preferences - Control Panel Settings - Scheduled Tasks)

    -Travis

    Edit: I mention using Vista as I was assuming you do not have any 2008 servers yet.
    Reply With Quote Quote  

  8. Virtual Member undomiel's Avatar
    Join Date
    Sep 2007
    Location
    Bellevue, WA
    Posts
    2,813

    Certifications
    MCSA:2008, VCP4/5, CCA (XS), MCITP: EA/VA, MCSE, MCSA, Linux+, Security+, Server+, A+
    #32
    Recursive batch file programming. I like it! Good answer kaeves.
    Reply With Quote Quote  

  9. Junior Member Registered Member
    Join Date
    Apr 2016
    Posts
    1
    #33
    Reply With Quote Quote  

+ Reply to Thread
Page 2 of 2 First 12

Social Networking & Bookmarks