2011-07-11 130 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 /?