Jump to content

Script to find IP Third Octave in IP Address


Recommended Posts

Guest ZZMHume
Posted

Hello,

 

I my environment, I have a number of Office that are set up the same,

except they all have a Different IP Subnet...

 

i.e. 10.10.XXX.YYY

 

Where XXX is different in each Office.

Where YYY is a Different Computer in each Office.

 

Each Office has a SHARED Folder for keeping Data on the Primary System

(something like a server for storage).

 

My Goal is that have a Script of some sort that will do the following:

 

1. Run the Same Script on Each Machine, no matter where the system is

located

2. Find the IP Address of the system is was presently RAN on, not caring

if it was the Primary system or secondary...

3. Finding the Third Octave of the IP Address i.e. 10.10.XXX.1 ( grabing

the info of "XXX")

4. Next, taking the Info of "XXX" from Script previously ran and

inputting that info into a Mapping Command to MAP something as follows:

 

net use Z: \\10.10.XXX.1\Shared_Folder -persistant

  • Replies 3
  • Created
  • Last Reply
Guest David H. Lipman
Posted

Re: Script to find IP Third Octave in IP Address

 

From: "ZZMHume" <michael.hume@assembly.ab.ca>

 

| Hello,

|

| I my environment, I have a number of Office that are set up the same,

| except they all have a Different IP Subnet...

|

| i.e. 10.10.XXX.YYY

|

| Where XXX is different in each Office.

| Where YYY is a Different Computer in each Office.

|

| Each Office has a SHARED Folder for keeping Data on the Primary System

| (something like a server for storage).

|

| My Goal is that have a Script of some sort that will do the following:

|

| 1. Run the Same Script on Each Machine, no matter where the system is

| located

| 2. Find the IP Address of the system is was presently RAN on, not caring

| if it was the Primary system or secondary...

| 3. Finding the Third Octave of the IP Address i.e. 10.10.XXX.1 ( grabing

| the info of "XXX")

| 4. Next, taking the Info of "XXX" from Script previously ran and

| inputting that info into a Mapping Command to MAP something as follows:

|

| net use Z: \\10.10.XXX.1\Shared_Folder -persistant

|

 

Please ask in an appropriate Scripting news group.

 

NOTE: KiXtart has the macro @IPaddressX to provide IP info and the result can then be used

to extract the required data. KiXtart is the prefect scripting language for what you are

attempting.

 

--

Dave

http://www.claymania.com/removal-trojan-adware.html

Multi-AV - http://www.pctipp.ch/downloads/dl/35905.asp

Guest Anteaus
Posted

RE: Script to find IP Third Octave in IP Address

 

Here's a roughout of how you would do this with AutoIt:

 

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

$sharename = "myfiles"

 

$thisIP = userip("10.0.")

 

$octets = StringSplit($thisIP, ".")

 

$myServer= "10.0.0." & $octets[4]

 

$thisShare = "\\" & myServer & "\" & $sharename

 

DriveMapDel("Z:") ; Persistent share, so if you don't do this you cannot

re-map it.

 

sleep(500)

 

DriveMapAdd("Z:" , $thisShare, 1 ) ; (1 in flags field = persistent)

 

exit

 

 

func userIP($IPrange)

; Determines which of 4 LAN adapters has the local subnet:

; Messy code, could be improved, but hey it works!

$UserIP=""

$thisIP = @IPAddress1

If stringleft($thisIP,stringlen($IPrange)) = $IPrange then

$userIP=$thisIP

endif

$thisIP = @IPAddress2

If stringleft($thisIP,stringlen($IPrange)) = $IPrange then

$userIP=$thisIP

endif

$thisIP = @IPAddress3

If stringleft($thisIP,stringlen($IPrange)) = $IPrange then

$userIP=$thisIP

endif

$thisIP = @IPAddress4

If stringleft($thisIP,stringlen($IPrange)) = $IPrange then

$userIP=$thisIP

endif

 

Return $userIP

endfunc

-----------

 

Adapted from a similar script. Might contain a few tpyos so watch out.

 

Autoit compiler: http://www.autoitscript.com

 

"ZZMHume" wrote:

 

> net use Z: \\10.10.XXX.1\Shared_Folder -persistant

Guest Pegasus \(MVP\)
Posted

Re: Script to find IP Third Octave in IP Address

 

 

"ZZMHume" <michael.hume@assembly.ab.ca> wrote in message

news:%23CNXX$zcIHA.5208@TK2MSFTNGP04.phx.gbl...

> Hello,

>

> I my environment, I have a number of Office that are set up the same,

> except they all have a Different IP Subnet...

>

> i.e. 10.10.XXX.YYY

>

> Where XXX is different in each Office.

> Where YYY is a Different Computer in each Office.

>

> Each Office has a SHARED Folder for keeping Data on the Primary System

> (something like a server for storage).

>

> My Goal is that have a Script of some sort that will do the following:

>

> 1. Run the Same Script on Each Machine, no matter where the system is

> located

> 2. Find the IP Address of the system is was presently RAN on, not

> caring if it was the Primary system or secondary...

> 3. Finding the Third Octave of the IP Address i.e. 10.10.XXX.1 (

> grabing the info of "XXX")

> 4. Next, taking the Info of "XXX" from Script previously ran and

> inputting that info into a Mapping Command to MAP something as follows:

>

> net use Z: \\10.10.XXX.1\Shared_Folder -persistant

>

>

 

Try this four-line batch file, and watch out for line wrap:

@echo off

for /F "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "IP Address"') do

set IP=%%a

for /F "tokens=3 delims=." %%a in ('echo %IP%') do set third=%%a

net use Z: \\10.10.%third%.1\Shared_Folder /persistent:yes

 

Watch out for the switch at the end, including the spelling: It is not

-persistant but

/persistent:yes


×
×
  • Create New...