NetSH on remote PC's
Hi, I've been testing netsh so I can use it in scripting a change but have come across a strange issue which I can't fathom. The aim is to change DNS server entries on remote machines. The command I'm running is; netsh -r <remote machine> interface ip set dns "local area connection" static <ip address> Which seems to execute fine with no error messages. However, I've found that the command has in fact changed the entries for the local machine and not the remote machine specified with the -r command. Am I running something wrong here? I've come across a suggestion to use psexec to run netsh remotely which is what I'll do but I wanted to know what I'm doing wrong with the -r switch Thanks.
May 17th, 2011 7:31am

Any chance your remote machine IP/name is actually your local machine? If you're using dns name see what it's resolving to. I'm able to use your command to set my local machines dns using the -r switch.
Free Windows Admin Tool Kit Click here and download it now
May 17th, 2011 9:20am

I believe the -r option only works to open a context on a remote machine, not to execute direct actions. MCP/MCSA/MCTS/MCITP
May 17th, 2011 9:24am

My suggestion is based on use of psexec (Sysinternals). Keep in mind that you have to allow access from client to server and set proper ports open. Name depends on regional settings. (Use show parameter if you are working in other than English environment, to find proper name.) psexec \\192.168.5.4 -d cmd.exe /c netsh.exe interface ip set dnsservers name="Local Area Connection" static 192.168.5.8 primary Basic data from Sysinternals web site Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,... ] cmd [arguments] computer Direct PsExec to run the application on the computer or computers specified. If you omit the computer name PsExec runs the application on the local system and if you enter a computer name of "\\*" PsExec runs the applications on all computers in the current domain. @file Directs PsExec to run the command on each computer listed in the text file specified. -a Separate processors on which the application can run with commas where 1 is the lowest numbered CPU. For example, to run the application on CPU 2 and CPU 4, enter: "-a 2,4" -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. -d Don't wait for application to terminate. Only use this option for non-interactive applications. -e Does not load the specified account's profile. -f Copy the specified program to the remote system even if the file already exists on the remote system. -i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session. -l Run process as limited user (strips the Administrators group and allows only privileges assigned to the Users group). On Windows Vista the process runs with Low Integrity. -n Specifies timeout in seconds connecting to remote computers. -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. -u Specifies optional user name for login to remote computer. -v Copy the specified file only if it has a higher version number or is newer on than the one on the remote system. -w Set the working directory of the process (relative to the remote computer). -x Display the UI on the Winlogon desktop (local system only). -priority Specifies -low, -belownormal, -abovenormal, -high or -realtime to run the process at a different priority. Use -background to run at low memory and I/O priority on Vista.
Free Windows Admin Tool Kit Click here and download it now
May 17th, 2011 2:12pm

Hi HimeshG73, Thanks for posting here. Did you try with IP address , hostname or FQDN ? you should first make sure the remote host is reachable. Please also try performing “netsh –r <remote machine host name,IP or FQDN>” and see if you can get “[<remote machine>] netsh>” in command prompt on your local server. Please also make sure the Remote Registry service has already been started on the remote computer. Thanks. Tiger Li Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
May 18th, 2011 3:20am

NetSH is amazing with remote but everyone forgets to give credentials. essentially "netsh -r W.X.Y.Z -u HOSTNAME\USER -p PASSWORD AndNowYourNetSHCommand" This also exists under tasklist and taskkill too.
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2012 10:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics