远程安装补丁

时间:2011-07-11 23:20:11

标签: scripting batch-file

我需要知道如何运行批处理脚本,该脚本将转到网络上的共享位置,将用户名和密码放入并运行指定的文件。我对脚本不是很好,到目前为止我找不到任何连贯的答案。我正在尝试在许多系统上运行软件补丁并尝试节省一点时间,无论是单独转到每个盒子还是在补丁盘中抛掷,或者使用Languard单独点击每个补丁(最多155个)。

到目前为止,我已经使用'net use'命令连接到共享,但无法让它使用用户名或密码,更不用说让它来执行补丁了。有人可以把它放在一个连贯的格式吗?我得到了很多语法,这很好但是它们总是使用额外的符号和星号,这可能有点令人困惑。也许是一个示例名称的例子?谢谢!

2 个答案:

答案 0 :(得分:0)

PsExec可以做你想做的事情

http://technet.microsoft.com/en-us/sysinternals/bb897553

usage: psexec \\computer [-u username [-p password]] [-s] [-c [-f]] [-d] program [arguments]


-u Specifies optional user name for login to remote computer. 
-p Specifies optional password for user name. If you omit this you will be prompted to enter a hidden password. 
-s Run remote process in the System account . 
-c Copy the specified program to the remote system for execution. If you omit this option then the application must be in the system's path on the remote system. 
-f Copy the specified program to the remote system even if the file already exists on the remote system. 
-d Don't wait for application to terminate. Only use this option for non-interactive applications. 

Examples
The following command launches an interactive command prompt on \\marklap:
psexec \\marklap cmd

This command executes IpConfig on the remote system with the /all switch, and displays the resulting output locally:

psexec \\marklap ipconfig /all

This command copies the program test.exe to the remote system and executes it interactively:

psexec \\marklap -c test.exe

Specify the full path to a program that is already installed on a remote system if its not on the system's path:

psexec \\marklap c:\bin\test.exe

src: http://www.governmentsecurity.org/forum/index.php?showtopic=1030

我现在正在linux上,所以我无法测试它。

for /l %%c in (1,1,254) do start psexec \\192.168.1.%%c -d -u administrator -p pass "net use Z: \\yourserver\user$ && Z:\update.exe && net use Z: /delete"

答案 1 :(得分:0)

您可以使用计划任务在70多台计算机上安排PSEXEC命令。命令行界面是SCHTASKS,因此您可以从管理员计算机一次安排所有这些。

C:\Windows\system32>schtasks /?

SCHTASKS /parameter [arguments]

Description:
    Enables an administrator to create, delete, query, change, run and
    end scheduled tasks on a local or remote system.

Parameter List:
    /Create         Creates a new scheduled task.

    /Delete         Deletes the scheduled task(s).

    /Query          Displays all scheduled tasks.

    /Change         Changes the properties of scheduled task.

    /Run            Runs the scheduled task on demand.

    /End            Stops the currently running scheduled task.

    /ShowSid        Shows the security identifier corresponding to a scheduled task name.

    /?              Displays this help message.

Examples:
    SCHTASKS
    SCHTASKS /?
    SCHTASKS /Run /?
    SCHTASKS /End /?
    SCHTASKS /Create /?
    SCHTASKS /Delete /?
    SCHTASKS /Query  /?
    SCHTASKS /Change /?
    SCHTASKS /ShowSid /?