Link to home
Start Free TrialLog in
Avatar of PVHS
PVHS

asked on

Error running WMIC against computers on network

I am stumped with the issue here. I am running a script that will change machines from Static IP addresses to DHCP. In the test environment everything works great, but when I expand my testing to a few live machines the script throws errors. The only thing that I can think is if there is a limitation of WMIC to only run on local subnet. There is no firewall between locations.

I attached the code from the batch file.

In the test environment, this is the result i get:

C:\>(
wmic /node:'m-is003' process call create 'cmd.exe /c "netsh interface ip set address name="Local Area Connection" source=dhcp"'
 echo 0
 wmic /node:'m-is003' process call create 'cmd /c "netsh interface ip set dns name="Local Area Connection" source=dhcp"'
 echo 0
 wmic /node:'m-is003' process call create 'cmd /c "netsh interface ip set wins name="Local Area Connection" source=dhcp"'
 echo 0
)
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ProcessId = 4116;
        ReturnValue = 0;
};

0
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ProcessId = 3936;
        ReturnValue = 0;
};

0
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ProcessId = 3824;
        ReturnValue = 0;
};

0


Here is what I get when I run it on live machines elsewhere:

C:\>(
wmic /node:'SCN92' process call create 'cmd.exe /c "netsh interface ip set address name="Local Area Connection" source=dhcp"'
 echo 0
 wmic /node:'SCN92' process call create 'cmd /c "netsh interface ip set dns name="Local Area Connection" source=dhcp"'
 echo 0
 wmic /node:'SCN92' process call create 'cmd /c "netsh interface ip set wins name="Local Area Connection" source=dhcp"'
 echo 0
)
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 8;
};

0
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 8;
};

0
Executing (Win32_Process)->Create()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 8;
};

0


If anyone has any ideas why this won't work because I am stumped and I haven't been able to find out what the returnvalue = 8 means. There are no logs in the eventviewer and all is the same on the workstations.

thanks,






FOR /F "tokens=1" %%A IN (C:\temp\test.txt) DO (
 
wmic /node:'%%A' process call create 'cmd.exe /c "netsh interface ip set address name="Local Area Connection" source=dhcp"'
echo %errorlevel%
wmic /node:'%%A' process call create 'cmd /c "netsh interface ip set dns name="Local Area Connection" source=dhcp"'
echo %errorlevel%
wmic /node:'%%A' process call create 'cmd /c "netsh interface ip set wins name="Local Area Connection" source=dhcp"'
echo %errorlevel%
)

Open in new window

Avatar of kyleb84
kyleb84
Flag of Australia image


(0x00000008) ERROR_OUTOFMEMORY = 8

I doubt that this is really the case, it's probably a WMIC custom error...


In any case, are you running this script on a server, then referencing the targets by their NETBIOS name?
Or are you running the script on each client?

If it's the former, I'd have a look at your permissions.
If it's the latter, try referencing the client by "localhost" instead of it's netbios name.

---------------------------

I've just ran that script on my laptop with the node "localhost", no error.
With the node "tuskes", no error. TUSKES is another laptop on my network.


Make sure you've got all the pre-req's installed on the client computers.

Avatar of maze-uk
maze-uk

Maybe you could disable the ICS service first:

SC %%A Stop "Windows Firewall/Internet Connection Sharing"
Wmic...
wmic...
SC %%A Start "Windows Firewall/Internet Connection Sharing"

Also have a look here: http://msdn.microsoft.com/en-us/library/aa389290(VS.85).aspx
"WMI can be used to manage and access WMI data on remote computers. Remote connections in WMI are affected by the Windows Firewall and DCOM settings. In Windows Vista and later operating systems, User Account Control (UAC) may also require changes to some settings. For more information, see Connecting to WMI Remotely Starting with Vista."

ASKER CERTIFIED SOLUTION
Avatar of PVHS
PVHS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial