2011-07-11 53 views
0

我需要知道如何运行批处理脚本,该脚本将转到网络上的共享位置,将用户名和密码放入并运行指定的文件。我用脚本不太好,迄今为止我找不到任何连贯的答案。我试图在很多系统上运行软件补丁,并试图节省一些时间,分别单独进入每个盒子并在补丁盘中折腾或使用Languard单独点击每个补丁(最多155个)。远程安装补丁

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

回答

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" 
+0

非常好的信息。我不确定那是我在找什么。我可以肯定地将它用于onesies和twosies,但70多台机器会让我的系统停滞不前,并使修补过程非常漫长。我想到的基本上是在远程机器上执行一个脚本,指向他们从共享服务器(而不是我的盒子)安装补丁。这样我所要做的就是执行脚本并让它运行。 基本上,我是A点,我希望B点在C点执行该文件。我该怎么做? – Morgan

+0

我添加了一个可能有帮助的班轮 –

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 /?