What problems are you having with PSExec and W2k3 exactly? We use the two together extensively, in a 500+ W2k3 server environment...
In fact, the whole PSTools suite rocks my world.
EDIT:
This is a followup to your edit of the original ticket.
The problem you're encountering is that "copy" is a function of CMD.exe. It doesn't exist as its own executable in its own right. Same as there is no Del.exe, or MD.exe etc.
If you want your example to work you need to invoke CMD via PSexec, and pass the copy command to that. Here's an example:
psexec -u MyDomain\MyUsername -p MyPassword \\MyServer cmd.exe /c copy c:\sys\util\monitor_localhost.bat blah.bat
The result is as follows:
==================================
PsExec v1.86 - Execute processes remotely Copyright (C) 2001-2007 Mark Russinovich Sysinternals - www.sysinternals.com
1 file(s) copied. cmd.exe exited on fcgwnt53 with error code 0.
==================================
There are many ways to automate (un)installation of MSIs, WMIC being one of them. Have you thought about a simpler approach, like a batch file that does:
rem Uninstall old program:
msiexec /qb /x {05EC21B8-4593-3037-A781-A6B5AFFCB19D}
rem Install new program:
msiexec /qb /i MyNewProgram.msi
(of course, replacing the GUID above with your program's GUID or Uninstall
key name).
Or, you could use the Automation interface to the Windows Installer.
Or, you could use WMI via VBScript or PowerShell to accomplish the same thing as WMIC will do. But it looks like WMI might be a bit hosed.
I don't have a fix for what I'm seeing, but I do have a couple of things you can try. I recently spent a bit of time troubleshooting WMI issues, so maybe a couple of those same techniques will work here.
First, here is a VBScript that should output the same thing as product get name
. Save it to a file getProductNames.vbs
and execute it.
Option Explicit
Dim strComputer
Dim objWMIService, colProducts, objProduct
Dim arrstrProducts(), i
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProducts = objWMIService.ExecQuery("Select * From Win32_Product")
i = 0
For Each objProduct in colProducts
ReDim Preserve arrStrProducts(i)
arrStrProducts(i) = objProduct.Name
i = i + 1
Next
WScript.Echo Join(arrStrProducts, vbNewLine)
Now, if that works, then try the same thing with wbemtest
.
- Launch the
wbemtest
program.
- Click
Connect...
- Change
root\default
to root\cimv2
, then click Connect
.
- Click
Query...
- Enter
Select * from Win32_Product
, then click Apply
.
This should return a list of products. If it does, then WMI is probably fine, and something is up with WMIC. If the script worked, but this did not, try the following at a Command Prompt:
regsvr32 wbemdisp.dll
then run the wbemtest
query again.
If neither the script nor the wbemtest
work, then probably WMI is super hosed, and you'll have to repair it.
Best Answer
I'd strongly recommend moving away from WMIC.EXE, and use PowerShell instead. PowerShell lets you use RPC to access the remote server's WMI interface, negating the need for PsExec. Although PsExec is a useful tool, I'd only use it if absolutely necessary, as it creates a service on the remote server, the newly created remote service then spawns a process to run your code, and the service is then supposed to auto-delete. However, I've come across servers that have failed PsExec services, and numerous orphaned processes that have failed for one or another reason. So, with my preaching over, here's an equivalent using PowerShell: