Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Win2003 batch can be run alone, but joining the task schedule cannot be run.

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

My environment introduction:

Win2003

Run--\ 172.16.6.218

Access another sql backup folder and copy it to the local E disk, and delete the backup data from 3 days ago, and use the following command (already available):

@ echo off

Cd / d "E:\ WMS-bak"

Forfiles / p E:\ WMS-bak / s / m * .bak / d-3 / c "cmd / c del @ path"

Net use\ 172.16.6.218\ g\ MSSQL11.MSSQLSERVER\ MSSQL\ Backup password / user:nameadmin

Copy / z\ 172.16.6.218\ g\ MSSQL11.MSSQLSERVER\ MSSQL\ Backup E:\ WMS-bak

Exit

Parse commands:

1) the cd command is simple and won't ask Baidu .

2) forfiles orders you not to? Are you sure you won't?

Forfiles command:

Forfiles [/ p Path] [/ m SearchMask] [/ s] [/ c Command] [/ d [{+ | -}] [{MM / DD / YYYY | DD}]]

Parameter list

/ p Path

Specify Path, indicating where to start the search. The default folder is the current working directory, which is obtained by typing a full stop (.) Specify.

/ m SearchMask

Search for files by SearchMask. The default SearchMask is. .

/ s

Instructs forfiles to search in subdirectories.

/ c Command

Runs the specified Command on each file. Command strings with spaces must be enclosed in quotation marks. The default Command is "cmd / c echo @ file".

/ d [{+ | -}] [{MM / DD / YYYY | DD}]

Select files whose date is greater than or equal to (+) (or less than or equal to (-) the specified date, where MM / DD / YYYY is the specified date and DD is the current date minus DD days. If + or-is not specified, + is used. The valid range for DD is 0-32768.

/?

Displays help at the command prompt.

Delete files from three days ago

Forfiles / p i:/serverbak/2005 / s / m. / d-2 / c "cmd / c del @ file"

/ p specified path

/ s includes subdirectories

File name mask for / m lookup

/ d specifies the date, with absolute and relative dates, where-7 refers to 7 days before the current date

The command line run by / c represents the commands executed for each file. The command string should be enclosed in double quotes.

The default command is "cmd / c echo @ file". The following variables

Can be used in a command string:

@ file-returns the file name.

@ fname-returns a file name without an extension.

@ ext-returns only the extension of the file.

Path-returns the full path to the file.

Relpath-returns the relative path to the file.

Isdir-returns "TRUE" if the file type is a directory, or "FALSE" if it is a file.

Fsize-returns the file size in bytes.

Fdate-returns the date the file was last modified.

Ftime-returns the time when the file was last modified.

Example

To list all batch files on drive C:, type:

Forfiles / p echo @ file is a batch file / s / m*.bat / c "cmd / c"

3) net use command this command is a key point, my task plan does not have this item, add this will be able to run normally. When the main win2003 task plans to access the shared folder, you need to increase command line access (although I added the mapping local Z disk, but it is still not successful) may be a problem with the system mechanism. Password and nameadmin are your account number and password to access another server. If it's safer, I won't put it on it.

4) the copy command is simple and won't ask Baidu. Ha.

5) the command exit will not? Then you'd better not play with batch processing.

Please don't spray me. The main people who can read this article are those who have been studying for a long time and have some knowledge of the above simple commands. Xiaobai, let's make a detour. Ha.

The task plan is finally running: after querying a lot of information, none of them can solve the problem, and it is finally done.

Normal operating conditions:

1. First determine whether the user is an administrator user. Of course, many people now use administrator.

2. Make sure that the "service" has two service guarantees started:

Remote Procedure Call (RPC)

Task Scheduler

3. Net use\ 172.16.6.218\ g\ MSSQL11.MSSQLSERVER\ MSSQL\ Backup Holley2016 / user:administrator

This needs to be placed before the command that you need to access the shared folder of the shared server.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report