using PSExec to run NetSH

  • Thread starter Thread starter MatthewBrown
  • Start date Start date
M

MatthewBrown

Hello,


I am interested in running NetSH on all of the computers on my domain.

The easist way I can fathom doing this is with PSExec, the only problem
being that you need to nest the name of the adapter in double quotes
within the NetSH arguments.

Here's what I figured would work:

psexec \\helpdesk-tester -u administrator -p pass netsh "interface ip
set address ""Local Area Connection"" dhcp"
Produced:
The following command was not found: "interface ip set address Local
Area Connection dhcp".


I then tried:
psexec \\helpdesk-tester -u administrator -p pass netsh "interface ip
set address \"Local Area Connection\" dhcp"
Which produced:
The following command was not found: "interface ip set address Local"
Area "Connection dhcp".


And last but not least:
psexec \\helpdesk-tester -u administrator -p pass netsh "interface ip
set address \"Local Area Connection"\ dhcp"

The following command was not found: "interface up set address Local"
Area Connection" dhcp.



There seems to be little to no logic here. So, there must be a proper
way that PSExec works for double quotes.

Please help!


Thanks,

Matt
 
Hello,


I am interested in running NetSH on all of the computers on my domain.

The easist way I can fathom doing this is with PSExec, the only problem
being that you need to nest the name of the adapter in double quotes
within the NetSH arguments.

Here's what I figured would work:

psexec \\helpdesk-tester -u administrator -p pass netsh "interface ip
set address ""Local Area Connection"" dhcp"
Produced:
The following command was not found: "interface ip set address Local
Area Connection dhcp".


I then tried:
psexec \\helpdesk-tester -u administrator -p pass netsh "interface ip
set address \"Local Area Connection\" dhcp"
Which produced:
The following command was not found: "interface ip set address Local"
Area "Connection dhcp".


And last but not least:
psexec \\helpdesk-tester -u administrator -p pass netsh "interface ip
set address \"Local Area Connection"\ dhcp"

The following command was not found: "interface up set address Local"
Area Connection" dhcp.



There seems to be little to no logic here. So, there must be a proper
way that PSExec works for double quotes.

Please help!


Thanks,

Matt

Try this:

psexec \\TestPC -u name -p pw netsh interface ip set address "Local Area
Connection" dhcp

Note that the command is likely to trip over itself because you're
changing the IP parameters of the target PC while psexec.exe is
active. To avoid this you may have to use psexec.exe to spawn
a delayed child command processor on the target machine that
runs the netsh command.
 
Thanks for the response.


Yea I see... it appears to "freeze."

But it worked! This makes me very very happy!


Thanks!

Matt
 
Back
Top