PCbanter

PCbanter (http://www.pcbanter.net/index.php)
-   Windows 7 Forum (http://www.pcbanter.net/forumdisplay.php?f=48)
-   -   use netsh in batch file to configure crossover cable conn. 2 w7computers (http://www.pcbanter.net/showthread.php?t=1102441)

Mike S[_4_] December 7th 17 05:48 AM

use netsh in batch file to configure crossover cable conn. 2 w7computers
 
I'm trying to use a batch file to configure the Local Area Connections
on 2 w7 computers so the user can xfer files using a crossover ethernet
cable. This is for a guy who doesn't want to use a router, switch, or ad
hoc wifi connection. He is not comfortable with changing settings, so
I'm trying to make this as easy as possible for him. After I get that
working I'll see if a Homegroup is the easiest way for a non-savvy user
to transfer files. But right now this batch file which has two problems,
it won't configure the default gateway to be the same as the Local Area
Connection ipv4 address, and when I try to configure a connection to
DHCP the command window showing the user what's happening just hangs
after it displays, "Windows IP Configuration". When I close the command
window and check the port properties they are set to DHCP. I am running
the batch file as an Administrator with the crossover cable is connected
to both boxes. If I configure just the IP address and Subnet Mask on
both machines and don't include the Default Gateway in the netsh command
it is left blank in the properties dialogs, and I can't ping between the
two machines. If I configure the Default Gateways to be the same as the
IPs after seeing the warning from w7, I still can't ping! The firewalls
are set to show me a dialog when something is blocked and there are no
warnings. I must be missing something basic. Any suggestions would be
appreciated.

@echo off
:::::::::::::::::::::::::::::::::::::::
echo Menu:
echo.
echo [1] Direct Connect - Computer 1
echo [2] Direct Connect - Computer 2
echo [0] Default - DHCP
echo.
:::::::::::::::::::::::::::::::::::::::
:choice
SET /P C=[1,2,0]?
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
for %%? in (0) do if /I "%C%"=="%%?" goto 0
goto choice
:::::::::::::::::::::::::::::::::::::::
:1
netsh interface ipv4 set address "Local Area Connection" static
192.168.1.1 255.255.255.0 192.168.1.1
netsh interface ipv4 show config
pause
goto end
:::::::::::::::::::::::::::::::::::::::
:2
netsh interface ipv4 set address "Local Area Connection" static
192.168.1.2 255.255.255.0 192.168.1.2
netsh interface ipv4 show config
pause
goto end
:::::::::::::::::::::::::::::::::::::::
:0
netsh interface ipv4 set address "Local Area Connection" dhcp
ipconfig /renew
netsh interface ipv4 show config
pause
goto end
:::::::::::::::::::::::::::::::::::::::
:end

Mike S[_4_] December 7th 17 06:42 AM

use netsh in batch file to configure crossover cable conn. 2 w7computers SOLVED
 
On 12/6/2017 8:48 PM, Mike S wrote:
I'm trying to use a batch file to configure the Local Area Connections
on 2 w7 computers so the user can xfer files using a crossover ethernet
cable. This is for a guy who doesn't want to use a router, switch, or ad
hoc wifi connection. He is not comfortable with changing settings, so
I'm trying to make this as easy as possible for him. After I get that
working I'll see if a Homegroup is the easiest way for a non-savvy user
to transfer files. But right now this batch file which has two problems,
it won't configure the default gateway to be the same as the Local Area
Connection ipv4 address, and when I try to configure a connection to
DHCP the command window showing the user what's happening just hangs
after it displays, "Windows IP Configuration". When I close the command
window and check the port properties they are set to DHCP. I am running
the batch file as an Administrator with the crossover cable is connected
to both boxes. If I configure just the IP address and Subnet Mask on
both machines and don't include the Default Gateway in the netsh command
it is left blank in the properties dialogs, and I can't ping between the
two machines.Â* If I configure the Default Gateways to be the same as the
IPs after seeing the warning from w7, I still can't ping! The firewalls
are set to show me a dialog when something is blocked and there are no
warnings. I must be missing something basic. Any suggestions would be
appreciated.

@echo off
:::::::::::::::::::::::::::::::::::::::
echo Menu:
echo.
echo [1] Direct Connect - Computer 1
echo [2] Direct Connect - Computer 2
echo [0] Default - DHCP
echo.
:::::::::::::::::::::::::::::::::::::::
:choice
SET /P C=[1,2,0]?
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
for %%? in (0) do if /I "%C%"=="%%?" goto 0
goto choice
:::::::::::::::::::::::::::::::::::::::
:1
netsh interface ipv4 set address "Local Area Connection" static
192.168.1.1 255.255.255.0 192.168.1.1
netsh interface ipv4 show config
pause
goto end
:::::::::::::::::::::::::::::::::::::::
:2
netsh interface ipv4 set address "Local Area Connection" static
192.168.1.2 255.255.255.0 192.168.1.2
netsh interface ipv4 show config
pause
goto end
:::::::::::::::::::::::::::::::::::::::
:0
netsh interface ipv4 set address "Local Area Connection" dhcp
ipconfig /renew
netsh interface ipv4 show config
pause
goto end
:::::::::::::::::::::::::::::::::::::::
:end


I found that in the Network and Sharing Center I can click on the
"Unidentified Network" then enable Network Discovery and File Sharing"
and then I can swap files back and forth.

Char Jackson December 7th 17 05:44 PM

use netsh in batch file to configure crossover cable conn. 2 w7 computers SOLVED
 
On Wed, 6 Dec 2017 21:42:35 -0800, Mike S wrote:

On 12/6/2017 8:48 PM, Mike S wrote:
I'm trying to use a batch file to configure the Local Area Connections
on 2 w7 computers so the user can xfer files using a crossover ethernet
cable.


FYI, if both PCs have Gigabit NICs, you don't need to use a crossover
cable. Any Ethernet cable will work. Sometimes that saves a trip to the
store, since most people don't have a crossover cable lying around.

This is for a guy who doesn't want to use a router, switch, or ad
hoc wifi connection. He is not comfortable with changing settings, so
I'm trying to make this as easy as possible for him. After I get that
working I'll see if a Homegroup is the easiest way for a non-savvy user
to transfer files. But right now this batch file which has two problems,
it won't configure the default gateway to be the same as the Local Area
Connection ipv4 address


Why on earth would you want the default gateway address to be the same
as the local address? What would that accomplish for you? If you don't
want a default gateway then simply don't configure one. Use the keyword
"none" in your command strings. When two hosts are on the same subnet,
like in your example, they don't need a default gateway to be able to
talk to each other.

Technically, they don't even need to be configured at all, in most
cases. Just connect the two PCs with any old Ethernet cable, assuming
both have GigE NICs, which most do these days, and both are configured
for DHCP, and let APIPA auto-assign addresses in the 169.254.0.0/16
subnet.

--

Char Jackson

Mike S[_4_] December 7th 17 11:48 PM

use netsh in batch file to configure crossover cable conn. 2 w7computers SOLVED
 
On 12/7/2017 8:44 AM, Char Jackson wrote:
On Wed, 6 Dec 2017 21:42:35 -0800, Mike S wrote:

On 12/6/2017 8:48 PM, Mike S wrote:
I'm trying to use a batch file to configure the Local Area Connections
on 2 w7 computers so the user can xfer files using a crossover ethernet
cable.


FYI, if both PCs have Gigabit NICs, you don't need to use a crossover
cable. Any Ethernet cable will work. Sometimes that saves a trip to the
store, since most people don't have a crossover cable lying around.


Good to know, thanks.

This is for a guy who doesn't want to use a router, switch, or ad
hoc wifi connection. He is not comfortable with changing settings, so
I'm trying to make this as easy as possible for him. After I get that
working I'll see if a Homegroup is the easiest way for a non-savvy user
to transfer files. But right now this batch file which has two problems,
it won't configure the default gateway to be the same as the Local Area
Connection ipv4 address


Why on earth would you want the default gateway address to be the same
as the local address? What would that accomplish for you? If you don't
want a default gateway then simply don't configure one. Use the keyword
"none" in your command strings. When two hosts are on the same subnet,
like in your example, they don't need a default gateway to be able to
talk to each other.

Technically, they don't even need to be configured at all, in most
cases. Just connect the two PCs with any old Ethernet cable, assuming
both have GigE NICs, which most do these days, and both are configured
for DHCP, and let APIPA auto-assign addresses in the 169.254.0.0/16
subnet.


Yes this works, thanks. I had thought the gateway had to be defined so
because the packets were sent there.

Char Jackson December 8th 17 03:22 AM

use netsh in batch file to configure crossover cable conn. 2 w7 computers SOLVED
 
On Thu, 7 Dec 2017 14:48:27 -0800, Mike S wrote:

On 12/7/2017 8:44 AM, Char Jackson wrote:
On Wed, 6 Dec 2017 21:42:35 -0800, Mike S wrote:

On 12/6/2017 8:48 PM, Mike S wrote:
I'm trying to use a batch file to configure the Local Area Connections
on 2 w7 computers so the user can xfer files using a crossover ethernet
cable.


FYI, if both PCs have Gigabit NICs, you don't need to use a crossover
cable. Any Ethernet cable will work. Sometimes that saves a trip to the
store, since most people don't have a crossover cable lying around.


Good to know, thanks.

This is for a guy who doesn't want to use a router, switch, or ad
hoc wifi connection. He is not comfortable with changing settings, so
I'm trying to make this as easy as possible for him. After I get that
working I'll see if a Homegroup is the easiest way for a non-savvy user
to transfer files. But right now this batch file which has two problems,
it won't configure the default gateway to be the same as the Local Area
Connection ipv4 address


Why on earth would you want the default gateway address to be the same
as the local address? What would that accomplish for you? If you don't
want a default gateway then simply don't configure one. Use the keyword
"none" in your command strings. When two hosts are on the same subnet,
like in your example, they don't need a default gateway to be able to
talk to each other.

Technically, they don't even need to be configured at all, in most
cases. Just connect the two PCs with any old Ethernet cable, assuming
both have GigE NICs, which most do these days, and both are configured
for DHCP, and let APIPA auto-assign addresses in the 169.254.0.0/16
subnet.


Yes this works, thanks. I had thought the gateway had to be defined so
because the packets were sent there.


A gateway is only used when traffic is destined for a non-local subnet.
In your case, all of the traffic is confined to a single subnet, so a
gateway isn't required.

--

Char Jackson

Mike S[_4_] December 8th 17 05:49 AM

use netsh in batch file to configure crossover cable conn. 2 w7computers SOLVED
 
On 12/7/2017 6:22 PM, Char Jackson wrote:
On Thu, 7 Dec 2017 14:48:27 -0800, Mike S wrote:

On 12/7/2017 8:44 AM, Char Jackson wrote:
On Wed, 6 Dec 2017 21:42:35 -0800, Mike S wrote:

On 12/6/2017 8:48 PM, Mike S wrote:
I'm trying to use a batch file to configure the Local Area Connections
on 2 w7 computers so the user can xfer files using a crossover ethernet
cable.

FYI, if both PCs have Gigabit NICs, you don't need to use a crossover
cable. Any Ethernet cable will work. Sometimes that saves a trip to the
store, since most people don't have a crossover cable lying around.


Good to know, thanks.

This is for a guy who doesn't want to use a router, switch, or ad
hoc wifi connection. He is not comfortable with changing settings, so
I'm trying to make this as easy as possible for him. After I get that
working I'll see if a Homegroup is the easiest way for a non-savvy user
to transfer files. But right now this batch file which has two problems,
it won't configure the default gateway to be the same as the Local Area
Connection ipv4 address

Why on earth would you want the default gateway address to be the same
as the local address? What would that accomplish for you? If you don't
want a default gateway then simply don't configure one. Use the keyword
"none" in your command strings. When two hosts are on the same subnet,
like in your example, they don't need a default gateway to be able to
talk to each other.

Technically, they don't even need to be configured at all, in most
cases. Just connect the two PCs with any old Ethernet cable, assuming
both have GigE NICs, which most do these days, and both are configured
for DHCP, and let APIPA auto-assign addresses in the 169.254.0.0/16
subnet.


Yes this works, thanks. I had thought the gateway had to be defined so
because the packets were sent there.


A gateway is only used when traffic is destined for a non-local subnet.
In your case, all of the traffic is confined to a single subnet, so a
gateway isn't required.


Very clear explanation, thank you.



All times are GMT +1. The time now is 07:55 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2006 PCbanter
Comments are property of their posters