1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Schtasks -- upated and not working

Discussion in 'Networking' started by wisdum, Jun 5, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    Cool

    This is opening up a wide variety of options now. I realize that vbscript can all that i want and far more.. but call me old school (i love batch files!)

    Now, to create a batch that will copy the spybot logs to the server for review....

    Stumped, im sure ill need your help soon enough!

    Thanks again!

    wis
     
  2. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    Well, once again im sure their is an "easier" or "better" way to do this with a vbScript... however im old school:

    In Scheduled Tasks, where does it actually save the .job files? I can see in the log that it is running the task 'spybot.job' but that file is not on my computer. I have tried to search with Search System Files, Search Hidden Files/folders and Search Subfolders all enabled and it still does not bring anything up.

    Is this something that is just a registry key, and not an actual file?

    The reason i want to find the file involves my script running an IF NOT EXIST where it looks for the job, if it doesn't exist, it schedules it.. pretty simple except i can't find the stupid files...

    wis
     
  3. StumpedTechy

    StumpedTechy

    Joined:
    Jul 7, 2004
    Messages:
    7,234
    Okay now your asking the easy stuff -

    Jobs can be seen 2 ways -

    Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks
    OR
    Start -> Run -> \\Remote computer name -> Scheduled Tasks

    They are kept in C:\windows\tasks and are *.job files.
     
  4. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    Thanks again Stumped... i really apprecaite all your help. I have compiled a small batch script and i thought i would share it with everyone incase they want to do something similar...

    I left out the authentication... :D

    echo off
    REM Computer Startup Script
    REM Written by Andy -- Wisdum
    REM V1.1


    REM Enables Remote Desktop
    reg add "hklm\system\currentcontrolset\control\terminal server" /f /v fDenyTSConnections /t REG_DWORD /d 0

    REM copy Shortcut to desktop from share on server
    REM copy /Y \\cccs-xan.watchwest\SysVol\cccs-xan.watchwest\Policies\{686578E5-BA69-4DBB-B2A3-21DBB153D7EA}\User\Scripts\Logon\WatchServerShares.lnk "%userprofile%\desktop\"
    REM copy /Y \\cccs-xan.watchwest\SysVol\cccs-xan.watchwest\Policies\{686578E5-BA69-4DBB-B2A3-21DBB153D7EA}\User\Scripts\Logon\WATCh_PUBLIC_SHARE.lnk "%userprofile%\desktop\"



    REM ------------------------------------------------------------------------------------
    REM --------------------------------Schedule Section------------------------------------
    REM ------------------------------------------------------------------------------------
    REM -------------------------------------Start------------------------------------------

    REM Autologoff user at 1:00 AM
    IF NOT EXIST "%SYSTEMDRIVE%"\WINDOWS\TASKS\autologoff.job. (schtasks /create /TN autologoff /RU ******/RP *******/SC daily /ST 01:00:00 /TR "%SystemRoot%"\System32\logoff.exe.)

    REM Schedule reboot
    IF NOT EXIST "%SYSTEMDRIVE%"\WINDOWS\TASKS\autoreboot.job. (schtasks /create /TN autoreboot /RU *****/RP ********/SC daily /ST 05:00:00 /TR "%SystemRoot%"\System32\shutdown.exe -r -t 60.)

    REM Schedule Spybot Scan
    IF NOT EXIST "%SYSTEMDRIVE%"\WINDOWS\TASKS\spybot.job. (schtasks /create /TN Spybot /RU **** /RP ******/SC daily /ST 05:20:00 /TR "C:\Progra~1\Spybot\SpybotSD.exe /taskbarhide /autoupdate /autoimmunize /autocheck /autofix /autoclose".)

    REM Schedule Spybot Log Backup
    IF NOT EXIST \\192.168.1.254\Logs\spybot\"%COMPUTERNAME%". (mkdir \\192.168.1.254\Logs\Spybot\"%COMPUTERNAME%".)
    IF NOT EXIST "%SYSTEMDRIVE%"\WINDOWS\TASKS\spybotbackup.job. (schtasks /create /TN spybotbackup /RU ******/RP ****** /SC daily /ST 05:55:00 /TR \\192.168.1.254\Logs\spybot\spybotbackup.bat.)

    REM Schedules Defrag
    IF NOT EXIST "%SYSTEMDRIVE%"\WINDOWS\TASKS\defrag.job. (schtasks /create /TN defrag /RU **** /RP ***** /SC daily /ST 01:00:00 /TR "defrag %systemdrive%".)

    REM -------------------------------------------------------------------------------------
    REM -------------------------------------End of Schedule Section-------------------------
    REM -------------------------------------------------------------------------------------


    This uses a spybot.msi that i created... but yeah, i think it is pretty self explanitory. Oh, and the defragger is really handy to take that task from the users (who are stupid) and have it automated.

    Im sure their is a better way to do it than this...but hey, why not. The only problem that i see with this is a clear text username and password of a limited administrative account. With echo off it wont show to the user, but if someone knew what was going on and had a packet sniffer im sure they could compromise the credentials...

    Anyone have any comments on this or suggestions?

    wisdum
     
  5. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    I guess i should have mentioned that the following line runs a batch on an open share on the server that simply copies the spybot logs to the server in a folder that is the same name as the computer (%COMPUTERNAME%)... just to clear things up.

    IF NOT EXIST "%SYSTEMDRIVE%"\WINDOWS\TASKS\spybotbackup.job. (schtasks /create /TN spybotbackup /RU ******/RP ****** /SC daily /ST 05:55:00 /TR \\192.168.1.254\Logs\spybot\spybotbackup.bat.)

    this simply schedules the other batch that copies the files to run... a nice, centralized backup of the spybot logs on the server.

    wis
     
  6. dvdo

    dvdo

    Joined:
    Jun 24, 2007
    Messages:
    3
    :cool: Use PSEXEC (SysInternals tool [owned by Microsoft]) as follows:

    psexec \\hostname schtasks /create /sc weekly /mo 2 /st 21:00:00 /tn "Sync Tool" /tr "C:\Temp\Tools\sync.BAT" /ru "System"

    I was researching this for a project and came up with this.
     
  7. dvdo

    dvdo

    Joined:
    Jun 24, 2007
    Messages:
    3
    Btw, EULA acceptance is required by MS and these REG commands will bypass EULA prompt:

    REG ADD "HKCU\Software\Sysinternals" /f
    REG ADD "HKCU\Software\Sysinternals\PsExec" /f
    REG ADD "HKCU\Software\Sysinternals\PsExec" /v "EulaAccepted" /t REG_DWORD /d 1 /f
     
  8. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    I have never noticed psexec having a EULA. That is a first for me. How does it affect it? I haven't noticed it not working... are those keys required?

    wis

    PS. This thread was a great help and i have been using the knowledge from it on my network for a year now.
     
  9. dvdo

    dvdo

    Joined:
    Jun 24, 2007
    Messages:
    3
    That EULA has been required since Microsoft's acquisition of SysInternals. The older versions of their tools may not have the EULA acceptance, but most of the newer ones do. It should not affect their use, so long and you have the above REG keys in queue/merged.
     
  10. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    Ahh, mine is an old copy ive had for a long time... im sure that is why it worked.

    thanks for the update!
     
  11. vmbriggs

    vmbriggs

    Joined:
    Aug 3, 2007
    Messages:
    2
    I've been having this same problem for weeks...Tried everything, even running the .bat as a startup script, but it still applied user credentials. If I put it only in the computer part of the policy, it did not create at all.
     
  12. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    Awhile back Microsoft released an update that broke schtasks. I have never been able to get it to work like that again. This is unofficially now unsolved again.... has anyone been able to make this work recently? I think the update came out some time this last winter.

    wis
     
  13. vmbriggs

    vmbriggs

    Joined:
    Aug 3, 2007
    Messages:
    2
    I had read a few places that the recent change MS made in the task schedule is to limit the cache that it uses when creating a task. I had originally had a login script that tried to schedule 2 seperate tasks. I found that if I limit it to one, and wait at least 10-15 minutes before trying to schedule another, then the work fine.
     
  14. wisdum

    wisdum Thread Starter

    Joined:
    Dec 1, 2005
    Messages:
    131
    wow, that sucks

    I will try that out i guess.
     
  15. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/472904

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice