Batch bat schtasks start remote application __bat

Source: Internet
Author: User
Tags net time schtasks

Description:

1, if the command can not run, please add chcp 437, or the cmd window to modify the properties of 437;

2, the bat can not be similar to schtasks name, and the bat directory also can not protect schtasks files such as, otherwise it may be the cycle of execution schtasks;


@echo off

NET use \\192.168.5.5\IPC$ "Luke"/user: "Administrator"

for/f "Tokens=7 delims="%%a in (' Net time \\192.168.5.5 ') do (set Dsttime=%%a) & (Goto:next)
: Next


Echo Current server time:%dsttime% >>c:\a.txt


set/a hh=%dsttime:~0,2%
Echo hh=%hh% >>c:\a.txt


set/a mm=%dsttime:~3,2%
Echo mm=%mm% >>c:\a.txt


set/a ss=%dsttime:~6,2%
Echo ss=%ss% >>c:\a.txt


If%ss% geq set/a ss=%ss%-60 & set/a mm=%mm%+1


If%mm% geq set/a mm=%mm%-60 & set/a hh=%hh%+1

If%hh%==24 set/a hh=0

Echo Timed Time:%hh%:%mm%>>c:\a.txt


If%mm% LSS 10 (
Echo is less than 10========= >>c:\a.txt
echo schtasks/create/tn test/tr calc/sc once/st 15:01/f >>c:\a.txt
schtasks/create/s 192.168.5.5/u administrator/p luke/sc once/st%hh%:0%mm%/F
echo minute is less than 10, execution is complete. >>c:\a.txt
)


If%mm% GEQ 10 (
CHCP 437
Echo is greater than 10========= >>c:\a.txt
schtasks/create/s 192.168.5.5/u administrator/p luke/sc once/st%hh%:0%mm%/F
echo minute is greater than 10, execution is complete. >>c:\a.txt
)

Pause

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.