• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 559
  • Last Modified:

Run command on only one of two NICs

Can I run a command or batch file on a specific NIC if a server has two NIC cards?  
0
fmontero
Asked:
fmontero
  • 22
  • 13
  • 7
  • +4
17 Solutions
 
mt_spyCommented:
if you are using windows you can use this command to view the number of each nic
   >netsh interface ip4 show interface

then you can target each nic by its number ex to add ip

   >netsh interface ip4 add address name=[nic number you want] source=static address=192.168.1.20
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
@mt_spy - small typo in your cmd, should be:
netsh interface ipv4 show interface

Open in new window

@fmontero - what command are you trying to run?
0
 
fmonteroAuthor Commented:
I'm trying to run a comand to restart a restart remote PCs which is another question i have open with expert exchange, keeping getting Access error (5))
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
fmonteroAuthor Commented:
1. ist attempt;
shutdown /m \\<IP> /r
Access error (5)

2. 2nd attempt:
psshutdown.exe \\pcname -t 10 -f -u <administrator account> -p <password>

error:
couldn't access \\pcname
the system cannot find the file specified

3. 3rd attempt:
ran the same command for ps shutdown but with runas
-same error

I have documented other attempts that I have tried as well (will find those and post as well).  really REALLY would help me out since the remote
machines are re-cloned each week and I need to be able to run the same command on the "new'clones each week without having to keep going
to them and make changes (defeats purpose of remoting in).
0
 
fmonteroAuthor Commented:
also tried this:

no good, here's what i got for both commands.

C:\>psexec \\host11 -u user -p pw -c -f c:\psshutdown.exe -r -t 0
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
Couldn't access host11:
The system cannot find the file specified.
 
then for the sutdown command:
shutdown.exe -i
 
C:\>shutdown.exe -i
host11: Access is denied.(5)
C:\>
0
 
fmonteroAuthor Commented:
sorry I keep commenting.  i just keep remembering small details that might help.  these machines are NOT on a domain,
 all standalone, but i have admin account to all (same since they are cloned) and can ping.

also tied this below:

C:\>psexec \\host11 -u user -p pw -c -f c:\WINDOWS\system32\shutdown.exe -r -t 0

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
The specified application is not on the path.

C:\>

tried this too.

C:\>psexec \\host11 -u user -p pw -c -f c:\WINDOWS\system32\shutdown.exe -r -t 0


PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

The specified application is not on the path.


C:\>
0
 
erobbyCommented:
Sounds like you have a RPC or firewall problem. What OS?   Can you open the event log or registry remotely?
0
 
ReneGeCommented:
-From another PC, can you access: \\host11\admin$
-From host11, can you access: \\localhost\admin$
-Assuming you are running XP or Windows7 with Telnet enabled, in a dos prompt, try: telnet host11 135. Does the dos window goes blank?
-When you ping "host11" does it at least outputs the good IP address?
-Is host11 in the same IP subnet?
-Go on host11 and verify it's MAC address. Make sure it is unik, compared with other PCs
-What are the enabled services on your NIC's properties (Like "Client for Microsoft network", etc...)
-Like erobby, make sure you have no firewall enabled. If you know Windows firewall is disabled but suspect there may by another one. Try booting in safe mode with networking enabled.

The list could go very log, so I'll stop here for now.

Cheers,
Rene
0
 
Max_197Commented:
I ever used the following syntax:

psexec \\host11 -u user -p pw "c:\WINDOWS\system32\shutdown.exe" /r /t 0


and it works fine.
0
 
fmonteroAuthor Commented:
Thanks ReneGe, Here's what i got in response to your response:

-From another PC, can you access: \\host11\admin$
 answer: yes I can

-From host11, can you access: \\localhost\admin$
answer: yes I can

-Assuming you are running XP or Windows7 with Telnet enabled, in a dos prompt, try: telnet host11 135. Does the dos window goes blank?

answer: yes it does


-When you ping "host11" does it at least outputs the good IP address?

answer: yes I can see the IP

-Is host11 in the same IP subnet?

answer: yes it is

-Like erobby, make sure you have no firewall enabled. If you know Windows firewall is disabled but suspect there may by another one. Try booting in safe mode with networking enabled.

-answer: firewall is NOT emnabled.

will get back to you soon on:

Go on host11 and verify it's MAC address. Make sure it is unik, compared with other PCs
-What are the enabled services on your NIC's properties (Like "Client for Microsoft network", etc...)


Cheers,
Frank
0
 
fmonteroAuthor Commented:
I also tried Max_197's solution:

psexec \\host11 -u user -p pw "c:\WINDOWS\system32\shutdown.exe" /r /t 0

answer:
couldn't access host11:
the system could not find the file specified
0
 
erobbyCommented:
FMentero:

can you connect via RPD

MSTSC /v:host11

Your IP info is fine you need to look at the services.  RPC (Remote Procedure Call) which will prevent you from running netsh and other commands remotely.
0
 
fmonteroAuthor Commented:
I tried MSTSC /v:host11
it connected to pc and asked for credentials, then when i typed them in, a dialog box popped up that said:
 rdp err rdp err
0
 
erobbyCommented:
try your event viewer

eventvwr \\host11

This will narrow things down to RDP not being enabled or an RPC Issue
0
 
fmonteroAuthor Commented:
i tried eventvwr \\host11

and itsays:

Umable to connect computer host11.  error was:

Access is denied

BUT then when I close that window, it conncts to the event viewer on host11
0
 
erobbyCommented:
Hey Fmontero,

Sorry didn't read the whole post

See if this provides a solution

http://www.numtopia.com/terry/blog/archives/2008/10/windows_2008_nlb_with_2_nics.cfm
0
 
fmonteroAuthor Commented:
these machines are not on domain, no fire wall enabled.  have to try to restart these machines without insatlling or touching remote machines

I DO know the admin credentials for remote machines (all the same).

I know it's alot (apologize for long post, but just trying to meet you half way) but here is what I have done and services on remote NICs:

1. ist attempt;
shutdown /m \\<IP> /r
Access error (5)

2. 2nd attempt:
psshutdown.exe \\pcname -t 10 -f -u <administrator account> -p <password>

error:
couldn't access \\pcname
the system cannot find the file specified


3. 3rd attempt:
ran the same command for ps shutdown but with runas
-same error



4. 4th attempt also tried this:

no good, here's what i got for both commands.

C:\>psexec \\host11 -u user -p pw -c -f c:\psshutdown.exe -r -t 0
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
Couldn't access host11:
The system cannot find the file specified.
 
then for the sutdown command:
shutdown.exe -i
 
C:\>shutdown.exe -i
host11: Access is denied.(5)
C:\>



5. 5th attempt sorry I keep commenting.  i just keep remembering small details that might help.  these machines are NOT on a domain,
 all standalone, but i have admin account to all (same since they are cloned) and can ping.

also tied this below:

C:\>psexec \\host11 -u user -p pw -c -f c:\WINDOWS\system32\shutdown.exe -r -t 0

PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
The specified application is not on the path.

C:\>

tried this too.

C:\>psexec \\host11 -u user -p pw -c -f c:\WINDOWS\system32\shutdown.exe -r -t 0


PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

The specified application is not on the path.


C:\>



6.6th attempt

 -From another PC, can you access: \\host11\admin$
 answer: yes I can

-From host11, can you access: \\localhost\admin$
answer: yes I can

-Assuming you are running XP or Windows7 with Telnet enabled, in a dos prompt, try: telnet host11 135. Does the dos window goes blank?

answer: yes it does


-When you ping "host11" does it at least outputs the good IP address?

answer: yes I can see the IP

-Is host11 in the same IP subnet?

answer: yes it is

-firewall is NOT emnabled.

7. 7th attempt

I tried MSTSC /v:host11
it connected to pc and asked for credentials, then when i typed them in, a dialog box popped up that said:

This computer can't connect to remote computer
Try connecting again.  If the problem continues, contact the owner of the remote computer or network administrator.


8. 8th attempt

 i tried eventvwr \\host11

and itsays:

Umable to connect computer host11.  error was:

Access is denied

BUT then when I close that window, it conncts to the event viewer on host11

9. 9th attempt

 services or remote Nic properties enabled:
-Client for MS Networks
-Qos Packet Scheduler
-File and Printer Sharing for Microsoft Networks
-Internet Protocol TCP/IP IPv4
0
 
Rob MinersCommented:
Try this

In order to use this feature, the Remote Registry service must be enabled on the remote computer.

Access to the Remote Registry or membership in the Administrators group on the remote computer is the minimum required to complete this procedure.

Use ipconfig to get your IP address's from the machine with 2 nics and then try this command substituting your IP addresses.

shutdown.exe /m \\192.168.1.2 /r /t 30 /d P:1:1
0
 
fmonteroAuthor Commented:
do I have to run command below on remote PC to enable Remote registry?

reg add "hklm\system\currentControlSet\Control\"Terminal server" /v "AllowTSConnections" /t REG_DWORD /d 0x1 /f

and also maybe

reg add "hklm\system\currentControlSet\Control\"Terminal server" /v "fDenyTSConnections" /t REG_DWORD /d 0x1 /f

then enable Terminal services

sc config TermService start= auto

the start it

net start Termservice

If i do have to run these commands on the remote PC, what command would i use to run them?
0
 
fmonteroAuthor Commented:
when I ran shutdown.exe /m \\192.168.1.2 /r /t 30 /d P:1:1

i got error

Access is denied(5).
0
 
Rob MinersCommented:
On the machine that you are trying to connect to, verify the Remote Registry Service is running

1.
Click Start, point to Settings, Control Panel, Administrative Tools, and then double-click Services.
 
2.
Verify that the Remote Registry Service has a status of Started.
0
 
Rob MinersCommented:
System error  5 - Access is denied

This is a permission issue. If the net view command fails with a "System error 5 has occurred. Access is denied." message,
1) make sure you are logged on using an account that has permission to view the shares on the remote computer.  
2) Need to cache credential: logon the same username and password on both computers or use net net use \\computername /user:username command.
3) Make sure the Netlogon service is running.

http://www.chicagotech.net/systemerrors.htm#System error  5 - Access is denied

0
 
fmonteroAuthor Commented:
remote regisrty is service has a started as status.

the Netlogon service is set to manual (and has NOT been started on remote machine).
0
 
erobbyCommented:
can you do a route print and post the results?
0
 
fmonteroAuthor Commented:
error 53 the network path was not found for  net use \\computername /user: username

I can get you the route print (not now) but the machines are on the same swith in the same physical space.  I can actualy go to the remote machine and enable stuff.  the reason i don't want to is because I have nearly 500 of them.  I believe there is a way to restart these machines without going over to them, especially when i have the admin credentials to them.
0
 
Rob MinersCommented:
The following are some common things to check when trying to resolve a System Error: 53 - Network path not found.

Verify that File & Printer Sharing is enabled on the remote machine.
Ensure all the necessary File & Printer Sharing ports are open on all routers/firewalls between the local and remote machines, and in any type of firewall software on the remote machine.
Confirm that the Operating System (O/S) is properly configured with regard to Names Resolution.
For Example: Open a CMD prompt, then Ping the remote machine by its Host Name.
Enable NetBios (i.e. NetBios over IP (NetBT/WINS)
0
 
erobbyCommented:
Is UAC running on these Machines?
0
 
Rob MinersCommented:
erobby has nailed it as I can reproduce both errors with UAC enabled.

0
 
Rob MinersCommented:
0
 
fmonteroAuthor Commented:
maybe we have to talk by phone or something casue, I'm still getting Access error (5)
0
 
erobbyCommented:
GO to the Control Panel and click on User Accounts.  

On the User Accounts screen click User Accounts again

On the Make Changes to User Account Screen click Change User Access Control Settings

Slide to bar all the way down to turn off
0
 
fmonteroAuthor Commented:
this is XP x64 , don't see those User Acct options.

Besides if i can go over to the machine and make these changes, it defeats the whole purpose of trying to restart remotely.  on 12/7 I stated the scenario (sorry probably should have restated.  the two test machines that i have in front of me are clones of the remote machines that I can't touch in the real world)

12/ 7/ scenario stated:

these machines are not on domain, no fire wall enabled.  I have to try to restart these machines without insatlling or touching remote machines

0
 
erobbyCommented:
They unfortunate part is if you can't touch the machines you can't do anything.  We already established that remote commands will not work and they are not on a domain.  You need someone physically there, there is no way around this one.

Sorry I couldn't have been of more help
0
 
fmonteroAuthor Commented:
It's NOT User account, it's the Local Secuirty Policy on the remote machine.  we just did here (I did have access to the remote machine, BUT a WMI script can be written to do it on the remote machine possibly)

on remote machine AdminTools>Loacl secuirty Policy>Local Policies>Secuirty Options>Network access: sharing and Secuirty Model for ect. = set to Classic.

if a WMI script can be written to do the above on a remote machine, you WILL be able to run the shutdown command on the standalone remote machine.
0
 
erobbyCommented:
Found this you can try: WMIC /node:machinename os call Reboot

But I have to admit I'm confused.

You have 2 machines that are clones of machines that you administer.
You can't touch the real world machines.
You've been able to make changes on the clones to allow you to administer them.

When you made the changes on the clone was the changes made from that machine?

If the change was made remotely what process did you use and why can't you duplicate it?

You are correct it is not a User account issue.  It's the services that allow you access be it a security policy or service that is not running.  Unless you can first correct that then you can't do anything to them.

0
 
fmonteroAuthor Commented:
sorry about the confusion erobby

MachineA = machine i can touch

MachineB = machine i will not be able to touch.

For testing/Building Purposes I willhave access to MachineB until we get it so that I do not have to touch it.

so I went on MachineB (even though not suppossed to touch it, but touched it to see if the Local policy was actually the issue, and it was, see cahnge made on MachineB below.  no I have to fugure out if a WMI script can achieve the same remotely)

on remote MachineB -> AdminTools>Loacl secuirty Policy>Local Policies>Secuirty Options>Network access: sharing and Secuirty Model for ect. = set to Classic.

0
 
Rob MinersCommented:
Sorry erobby I thought he was using windows 7 :(

Apparently 32 Bit is: %SystemRoot%\System32\Shutdown.exe
 
and 64 Bit is: %SystemRoot%\SysWOW64\Shutdown.exe

I haven't access to a 64 bit Computer to test with so it looks like you have to access %SystemRoot%\SysWOW64\Shutdown.exe

psexec \\gamer cmd
cd\
%SystemRoot%\SysWoW64\shutdown.exe /r /t 30 /d P:1:1
0
 
fmonteroAuthor Commented:
after i made that change, I ran below command on MachineA:

net use q: \\host1 \c$ /user:user
shutdown -r /m \\<IP>

and it shutdown MachineB down.
0
 
erobbyCommented:
So you ran your test and it worked you just have no way of verifying that it worked?

Ok Lets assume it did work what would be different about your environment?
0
 
fmonteroAuthor Commented:
It did work in our test environment, I saw it work and had access to both machines.  we verified here in person that it worked.  nothing would be different in remote environment.

 I just have to now be able to change below setting WITHOUT touching remote MachineB:

on remote MachineB -> AdminTools>Loacl secuirty Policy>Local Policies>Secuirty Options>Network access: sharing and Secuirty Model for ect. = set to Classic
0
 
erobbyCommented:
Ok so there is your condition.

Run your script, if it works you will be able to issue a shutdown command.  To ensure the machine did actually shutdown ping the machine name about 45 seconds to a minute after issuing the shutdown command.  The default shutdown timer is 30 second.  It the machine does not reply them the assumption is that it's down...provided you were able to ping it before
0
 
fmonteroAuthor Commented:
sorry, maybe I wasn't clear.  I have the two machines in front of me.  I saw machineB shutdown.  but I had to touch machineB and change

on remote MachineB -> AdminTools>Loacl secuirty Policy>Local Policies>Secuirty Options>Network access: sharing and Secuirty Model for ect. = set to Classic

after i did, i was able to shutdown machineB FROM machineA.  I was machineB, go down and restart.
0
 
erobbyCommented:
So we are back to were need someone physically there.

There is a setting that you need to change to remotely manage the workstations.
The workstations in their current configuration will not allow you to remotely manage them.
You have no controller in place like a Domain that you can issue remote commands from.

I'm sorry I couldn't have been more help.  I just can't seem to see a way to resolve your issue.

Thanks for allowing me to try and thanks for your patience.
0
 
fmonteroAuthor Commented:
although I was the one who eventully found the issue, it was only through, I was very impressed with the dilligent responses and attention to detail by the techs involved.
0
 
erobbyCommented:
Thanks for the points
0
 
fmonteroAuthor Commented:
No problem, you guys were very helpful.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 22
  • 13
  • 7
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now