dedri
asked on
execute cmd script on multiple computers
I have a script script.cmd which I want to execute on half of the computers in our organization.
Could you tell me how to do it?
Most of workstations are XP SP3, and a couple win7
Could you tell me how to do it?
Most of workstations are XP SP3, and a couple win7
If you want to stay away from PowerShell, you can use PsExec from the Sysinternals toolkit:
Make a list of servers/machines - Servers.txt and then run -
psexec @Servers.txt -c Script.cmd
This will copy over the script and then execute on each machine.
Make a list of servers/machines - Servers.txt and then run -
psexec @Servers.txt -c Script.cmd
This will copy over the script and then execute on each machine.
3rd possible way: simply wrap that script into an msi using any msi wrapper like exetomsi or wiww. That way, you don't even need to power on those machines, they will do "install" that setting whenever they power on and decide to accept that policy.
ASKER
ThinkSpaceSolutions, could you explain how to work with first script.
I found a script in this link which uses psexec, but I have a problem running it.
http://community.spiceworks.com/scripts/show/446-remote-execution-on-multiple-computers
If I run it manually here is the result
C:\temp\ExecMC>psexec \\computer1 -c \\server\share\scripts\Unr eg.cmd
Here is the content of the cmd file
########
@Echo off
Echo *
Echo * SIGNME AS COM SERVER
Echo *
signme.exe /unregserver
Echo *
Echo * REGISTER ASSEMBLY
Echo *
%WINDIR%\Microsoft.NET\Fra mework\v1. 1.4322\reg asm /unregister signme.base.dll /tlb /v
rem fin:
##########
------------Here is the result from execution of the command---------
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
*
'signme.exe' is not recognized as an internal or external command,
operable program or batch file.
* SIGNME AS COM SERVER
*
*
* REGISTER ASSEMBLY
*
Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
RegAsm error: Unable to locate input assembly: 'signme.base.dll'
Unreg.cmd exited on computer1 with error code 0.
-------------------------- ------
If I psexec the computer, browse the script on local folder and run it , it's executed successful.
Any idea how to fix it?
I found a script in this link which uses psexec, but I have a problem running it.
http://community.spiceworks.com/scripts/show/446-remote-execution-on-multiple-computers
If I run it manually here is the result
C:\temp\ExecMC>psexec \\computer1 -c \\server\share\scripts\Unr
Here is the content of the cmd file
########
@Echo off
Echo *
Echo * SIGNME AS COM SERVER
Echo *
signme.exe /unregserver
Echo *
Echo * REGISTER ASSEMBLY
Echo *
%WINDIR%\Microsoft.NET\Fra
rem fin:
##########
------------Here is the result from execution of the command---------
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
*
'signme.exe' is not recognized as an internal or external command,
operable program or batch file.
* SIGNME AS COM SERVER
*
*
* REGISTER ASSEMBLY
*
Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
RegAsm error: Unable to locate input assembly: 'signme.base.dll'
Unreg.cmd exited on computer1 with error code 0.
--------------------------
If I psexec the computer, browse the script on local folder and run it , it's executed successful.
Any idea how to fix it?
This is how I use it:
First, you should navigate to the location of the folder that file is located on your local machine. For example, my scripts are stored on my file server 'TSShare' (mapped as T:\) under the Scripts folder.
T:\Scripts>
Then I call my list of servers, add -c to copy to the servers, then the script:
T:\Scripts> @T:\Servers\ServerSet1.txt -c Script1.bat
Is this the same format you are using?
First, you should navigate to the location of the folder that file is located on your local machine. For example, my scripts are stored on my file server 'TSShare' (mapped as T:\) under the Scripts folder.
T:\Scripts>
Then I call my list of servers, add -c to copy to the servers, then the script:
T:\Scripts> @T:\Servers\ServerSet1.txt
Is this the same format you are using?
ASKER
sorry, I didn't understand your answer.
What I am doing is the following:
psexec \\computer1 -c \\server\share\scripts\Unr eg.cmd
or
psexec \\computer1 Unreg.cmd
or anything similar
And the output is
------------Here is the result from execution of the command---------
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
*
'signme.exe' is not recognized as an internal or external command,
operable program or batch file.
* SIGNME AS COM SERVER
*
*
* REGISTER ASSEMBLY
*
Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
RegAsm error: Unable to locate input assembly: 'signme.base.dll'
Unreg.cmd exited on computer1 with error code 0.
-------------------------- ------
If I do this:
psexec \\computer1 cmd
and on the prompt I run Unreg.cmd it is executed successful.
Anything different on both cases and idea how to make it working.
What I am doing is the following:
psexec \\computer1 -c \\server\share\scripts\Unr
or
psexec \\computer1 Unreg.cmd
or anything similar
And the output is
------------Here is the result from execution of the command---------
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
*
'signme.exe' is not recognized as an internal or external command,
operable program or batch file.
* SIGNME AS COM SERVER
*
*
* REGISTER ASSEMBLY
*
Microsoft (R) .NET Framework Assembly Registration Utility 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
RegAsm error: Unable to locate input assembly: 'signme.base.dll'
Unreg.cmd exited on computer1 with error code 0.
--------------------------
If I do this:
psexec \\computer1 cmd
and on the prompt I run Unreg.cmd it is executed successful.
Anything different on both cases and idea how to make it working.
Try creating a copy of your .cmd and changing the association to .bat.
ASKER
I tried changing the script file from .cmd to .bat , but the problem still exist, the same error message as above.
Why not use a wrapper like I recommended? As I described: it holds even more advantaged compared to psexec.
ASKER
McKnife, could you explain in more details your solution.
I cannot understand what to do when I create a msi package for this script.
I cannot understand what to do when I create a msi package for this script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry for late response. I haven't got any time recently. I'll try your solution and give you reply.
Please respond or finalize it, this question is growing old :)
ASKER
sorry, I didn't have time to test your solution. I was appointed to another project
Open in new window