Jump to content

Writing log even though device is NOT in the array


MattX
 Share

Go to solution Solved by iamtheky,

Recommended Posts

This script reads a load of IP addresses into an array, if the device has the IP address in the list then it will write it to a log file - this all works but for some reason if writes a log file with the details in even thought the device is NOT in the list.

I can't work out how to quit the script in this loop if the IP address is NOT listed. I've tried a ElseIf and quit after the Call("_FileWriteLog") but that fails. I also cannot work out why the log is still being created when the device IS NOT in the array. All I can think of is that the script is falling down the code and simply running the logging function - any tips of getting out of this so the log is NOT created if the IP is not listed  would be appreciated.

For $i = 1 To UBound($IPRANGE) - 1
    If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then
        Call("_FileWriteLog")
     EndIf
Next

Full:

Global $IPRANGE[509]
$IPRANGE[1] = "10.20.1.1"
$IPRANGE[2] = "10.20.1.2"
$IPRANGE[3] = "10.20.1.3"
$IPRANGE[4] = "10.20.1.4"
$IPRANGE[5] = "10.20.1.5"
$IPRANGE[6] = "10.20.1.6"
$IPRANGE[7] = "10.20.1.7"
$IPRANGE[8] = "10.20.1.8"
$IPRANGE[9] = "10.20.1.9"
$IPRANGE[10] = "10.20.1.10"
$IPRANGE[11] = "10.20.1.11"
$IPRANGE[12] = "10.20.1.12"
$IPRANGE[13] = "10.20.1.13"
$IPRANGE[14] = "10.20.1.14"
$IPRANGE[15] = "10.20.1.15"
$IPRANGE[16] = "10.20.1.16"
$IPRANGE[17] = "10.20.1.17"
$IPRANGE[18] = "10.20.1.18"
$IPRANGE[19] = "10.20.1.19"
$IPRANGE[20] = "10.20.1.20"
$IPRANGE[21] = "10.20.1.21"
$IPRANGE[22] = "10.20.1.22"
$IPRANGE[23] = "10.20.1.23"
$IPRANGE[24] = "10.20.1.24"
$IPRANGE[25] = "10.20.1.25"
$IPRANGE[26] = "10.20.1.26"
$IPRANGE[27] = "10.20.1.27"
$IPRANGE[28] = "10.20.1.28"
$IPRANGE[29] = "10.20.1.29"
$IPRANGE[30] = "10.20.1.30"
$IPRANGE[31] = "10.20.1.31"
$IPRANGE[32] = "10.20.1.32"
$IPRANGE[33] = "10.20.1.33"
$IPRANGE[34] = "10.20.1.34"
$IPRANGE[35] = "10.20.1.35"
$IPRANGE[36] = "10.20.1.36"
$IPRANGE[37] = "10.20.1.37"
$IPRANGE[38] = "10.20.1.38"
$IPRANGE[39] = "10.20.1.39"
$IPRANGE[40] = "10.20.1.40"
$IPRANGE[41] = "10.20.1.41"
$IPRANGE[42] = "10.20.1.42"
$IPRANGE[43] = "10.20.1.43"
$IPRANGE[44] = "10.20.1.44"
$IPRANGE[45] = "10.20.1.45"
$IPRANGE[46] = "10.20.1.46"
$IPRANGE[47] = "10.20.1.47"
$IPRANGE[48] = "10.20.1.48"
$IPRANGE[49] = "10.20.1.49"
$IPRANGE[50] = "10.20.1.50"
$IPRANGE[51] = "10.20.1.51"
$IPRANGE[52] = "10.20.1.52"
$IPRANGE[53] = "10.20.1.53"
$IPRANGE[54] = "10.20.1.54"
$IPRANGE[55] = "10.20.1.55"
$IPRANGE[56] = "10.20.1.56"
$IPRANGE[57] = "10.20.1.57"
$IPRANGE[58] = "10.20.1.58"
$IPRANGE[59] = "10.20.1.59"
$IPRANGE[60] = "10.20.1.60"
$IPRANGE[61] = "10.20.1.61"
$IPRANGE[62] = "10.20.1.62"
$IPRANGE[63] = "10.20.1.63"
$IPRANGE[64] = "10.20.1.64"
$IPRANGE[65] = "10.20.1.65"
$IPRANGE[66] = "10.20.1.66"
$IPRANGE[67] = "10.20.1.67"
$IPRANGE[68] = "10.20.1.68"
$IPRANGE[69] = "10.20.1.69"
$IPRANGE[70] = "10.20.1.70"
$IPRANGE[71] = "10.20.1.71"
$IPRANGE[72] = "10.20.1.72"
$IPRANGE[73] = "10.20.1.73"
$IPRANGE[74] = "10.20.1.74"
$IPRANGE[75] = "10.20.1.75"
$IPRANGE[76] = "10.20.1.76"
$IPRANGE[77] = "10.20.1.77"
$IPRANGE[78] = "10.20.1.78"
$IPRANGE[79] = "10.20.1.79"
$IPRANGE[80] = "10.20.1.80"
$IPRANGE[81] = "10.20.1.81"
$IPRANGE[82] = "10.20.1.82"
$IPRANGE[83] = "10.20.1.83"
$IPRANGE[84] = "10.20.1.84"
$IPRANGE[85] = "10.20.1.85"
$IPRANGE[86] = "10.20.1.86"
$IPRANGE[87] = "10.20.1.87"
$IPRANGE[88] = "10.20.1.88"
$IPRANGE[89] = "10.20.1.89"
$IPRANGE[90] = "10.20.1.90"
$IPRANGE[91] = "10.20.1.91"
$IPRANGE[92] = "10.20.1.92"
$IPRANGE[93] = "10.20.1.93"
$IPRANGE[94] = "10.20.1.94"
$IPRANGE[95] = "10.20.1.95"
$IPRANGE[96] = "10.20.1.96"
$IPRANGE[97] = "10.20.1.97"
$IPRANGE[98] = "10.20.1.98"
$IPRANGE[99] = "10.20.1.99"
$IPRANGE[100] = "10.20.1.100"
$IPRANGE[101] = "10.20.1.101"
$IPRANGE[102] = "10.20.1.102"
$IPRANGE[103] = "10.20.1.103"
$IPRANGE[104] = "10.20.1.104"
$IPRANGE[105] = "10.20.1.105"
$IPRANGE[106] = "10.20.1.106"
$IPRANGE[107] = "10.20.1.107"
$IPRANGE[108] = "10.20.1.108"
$IPRANGE[109] = "10.20.1.109"
$IPRANGE[110] = "10.20.1.110"
$IPRANGE[111] = "10.20.1.111"
$IPRANGE[112] = "10.20.1.112"
$IPRANGE[113] = "10.20.1.113"
$IPRANGE[114] = "10.20.1.114"
$IPRANGE[115] = "10.20.1.115"
$IPRANGE[116] = "10.20.1.116"
$IPRANGE[117] = "10.20.1.117"
$IPRANGE[118] = "10.20.1.118"
$IPRANGE[119] = "10.20.1.119"
$IPRANGE[120] = "10.20.1.120"
$IPRANGE[121] = "10.20.1.121"
$IPRANGE[122] = "10.20.1.122"
$IPRANGE[123] = "10.20.1.123"
$IPRANGE[124] = "10.20.1.124"
$IPRANGE[125] = "10.20.1.125"
$IPRANGE[126] = "10.20.1.126"
$IPRANGE[127] = "10.20.1.127"
$IPRANGE[128] = "10.20.1.128"
$IPRANGE[129] = "10.20.1.129"
$IPRANGE[130] = "10.20.1.130"
$IPRANGE[131] = "10.20.1.131"
$IPRANGE[132] = "10.20.1.132"
$IPRANGE[133] = "10.20.1.133"
$IPRANGE[134] = "10.20.1.134"
$IPRANGE[135] = "10.20.1.135"
$IPRANGE[136] = "10.20.1.136"
$IPRANGE[137] = "10.20.1.137"
$IPRANGE[138] = "10.20.1.138"
$IPRANGE[139] = "10.20.1.139"
$IPRANGE[140] = "10.20.1.140"
$IPRANGE[141] = "10.20.1.141"
$IPRANGE[142] = "10.20.1.142"
$IPRANGE[143] = "10.20.1.143"
$IPRANGE[144] = "10.20.1.144"
$IPRANGE[145] = "10.20.1.145"
$IPRANGE[146] = "10.20.1.146"
$IPRANGE[147] = "10.20.1.147"
$IPRANGE[148] = "10.20.1.148"
$IPRANGE[149] = "10.20.1.149"
$IPRANGE[150] = "10.20.1.150"
$IPRANGE[151] = "10.20.1.151"
$IPRANGE[152] = "10.20.1.152"
$IPRANGE[153] = "10.20.1.153"
$IPRANGE[154] = "10.20.1.154"
$IPRANGE[155] = "10.20.1.155"
$IPRANGE[156] = "10.20.1.156"
$IPRANGE[157] = "10.20.1.157"
$IPRANGE[158] = "10.20.1.158"
$IPRANGE[159] = "10.20.1.159"
$IPRANGE[160] = "10.20.1.160"
$IPRANGE[161] = "10.20.1.161"
$IPRANGE[162] = "10.20.1.162"
$IPRANGE[163] = "10.20.1.163"
$IPRANGE[164] = "10.20.1.164"
$IPRANGE[165] = "10.20.1.165"
$IPRANGE[166] = "10.20.1.166"
$IPRANGE[167] = "10.20.1.167"
$IPRANGE[168] = "10.20.1.168"
$IPRANGE[169] = "10.20.1.169"
$IPRANGE[170] = "10.20.1.170"
$IPRANGE[171] = "10.20.1.171"
$IPRANGE[172] = "10.20.1.172"
$IPRANGE[173] = "10.20.1.173"
$IPRANGE[174] = "10.20.1.174"
$IPRANGE[175] = "10.20.1.175"
$IPRANGE[176] = "10.20.1.176"
$IPRANGE[177] = "10.20.1.177"
$IPRANGE[178] = "10.20.1.178"
$IPRANGE[179] = "10.20.1.179"
$IPRANGE[180] = "10.20.1.180"
$IPRANGE[181] = "10.20.1.181"
$IPRANGE[182] = "10.20.1.182"
$IPRANGE[183] = "10.20.1.183"
$IPRANGE[184] = "10.20.1.184"
$IPRANGE[185] = "10.20.1.185"
$IPRANGE[186] = "10.20.1.186"
$IPRANGE[187] = "10.20.1.187"
$IPRANGE[188] = "10.20.1.188"
$IPRANGE[189] = "10.20.1.189"
$IPRANGE[190] = "10.20.1.190"
$IPRANGE[191] = "10.20.1.191"
$IPRANGE[192] = "10.20.1.192"
$IPRANGE[193] = "10.20.1.193"
$IPRANGE[194] = "10.20.1.194"
$IPRANGE[195] = "10.20.1.195"
$IPRANGE[196] = "10.20.1.196"
$IPRANGE[197] = "10.20.1.197"
$IPRANGE[198] = "10.20.1.198"
$IPRANGE[199] = "10.20.1.199"
$IPRANGE[200] = "10.20.1.200"
$IPRANGE[201] = "10.20.1.201"
$IPRANGE[202] = "10.20.1.202"
$IPRANGE[203] = "10.20.1.203"
$IPRANGE[204] = "10.20.1.204"
$IPRANGE[205] = "10.20.1.205"
$IPRANGE[206] = "10.20.1.206"
$IPRANGE[207] = "10.20.1.207"
$IPRANGE[208] = "10.20.1.208"
$IPRANGE[209] = "10.20.1.209"
$IPRANGE[210] = "10.20.1.210"
$IPRANGE[211] = "10.20.1.211"
$IPRANGE[212] = "10.20.1.212"
$IPRANGE[213] = "10.20.1.213"
$IPRANGE[214] = "10.20.1.214"
$IPRANGE[215] = "10.20.1.215"
$IPRANGE[216] = "10.20.1.216"
$IPRANGE[217] = "10.20.1.217"
$IPRANGE[218] = "10.20.1.218"
$IPRANGE[219] = "10.20.1.219"
$IPRANGE[220] = "10.20.1.220"
$IPRANGE[221] = "10.20.1.221"
$IPRANGE[222] = "10.20.1.222"
$IPRANGE[223] = "10.20.1.223"
$IPRANGE[224] = "10.20.1.224"
$IPRANGE[225] = "10.20.1.225"
$IPRANGE[226] = "10.20.1.226"
$IPRANGE[227] = "10.20.1.227"
$IPRANGE[228] = "10.20.1.228"
$IPRANGE[229] = "10.20.1.229"
$IPRANGE[230] = "10.20.1.230"
$IPRANGE[231] = "10.20.1.231"
$IPRANGE[232] = "10.20.1.232"
$IPRANGE[233] = "10.20.1.233"
$IPRANGE[234] = "10.20.1.234"
$IPRANGE[235] = "10.20.1.235"
$IPRANGE[236] = "10.20.1.236"
$IPRANGE[237] = "10.20.1.237"
$IPRANGE[238] = "10.20.1.238"
$IPRANGE[239] = "10.20.1.239"
$IPRANGE[240] = "10.20.1.240"
$IPRANGE[241] = "10.20.1.241"
$IPRANGE[242] = "10.20.1.242"
$IPRANGE[243] = "10.20.1.243"
$IPRANGE[244] = "10.20.1.244"
$IPRANGE[245] = "10.20.1.245"
$IPRANGE[246] = "10.20.1.246"
$IPRANGE[247] = "10.20.1.247"
$IPRANGE[248] = "10.20.1.248"
$IPRANGE[249] = "10.20.1.249"
$IPRANGE[250] = "10.20.1.250"
$IPRANGE[251] = "10.20.1.251"
$IPRANGE[252] = "10.20.1.252"
$IPRANGE[253] = "10.20.1.253"
$IPRANGE[254] = "10.20.1.254"
$IPRANGE[255] = "10.20.24.1"
$IPRANGE[256] = "10.20.24.2"
$IPRANGE[257] = "10.20.24.3"
$IPRANGE[258] = "10.20.24.4"
$IPRANGE[259] = "10.20.24.5"
$IPRANGE[260] = "10.20.24.6"
$IPRANGE[261] = "10.20.24.7"
$IPRANGE[262] = "10.20.24.8"
$IPRANGE[263] = "10.20.24.9"
$IPRANGE[264] = "10.20.24.10"
$IPRANGE[265] = "10.20.24.11"
$IPRANGE[266] = "10.20.24.12"
$IPRANGE[267] = "10.20.24.13"
$IPRANGE[268] = "10.20.24.14"
$IPRANGE[269] = "10.20.24.15"
$IPRANGE[270] = "10.20.24.16"
$IPRANGE[271] = "10.20.24.17"
$IPRANGE[272] = "10.20.24.18"
$IPRANGE[273] = "10.20.24.19"
$IPRANGE[274] = "10.20.24.20"
$IPRANGE[275] = "10.20.24.21"
$IPRANGE[276] = "10.20.24.22"
$IPRANGE[277] = "10.20.24.23"
$IPRANGE[278] = "10.20.24.24"
$IPRANGE[279] = "10.20.24.25"
$IPRANGE[280] = "10.20.24.26"
$IPRANGE[281] = "10.20.24.27"
$IPRANGE[282] = "10.20.24.28"
$IPRANGE[283] = "10.20.24.29"
$IPRANGE[284] = "10.20.24.30"
$IPRANGE[285] = "10.20.24.31"
$IPRANGE[286] = "10.20.24.32"
$IPRANGE[287] = "10.20.24.33"
$IPRANGE[288] = "10.20.24.34"
$IPRANGE[289] = "10.20.24.35"
$IPRANGE[290] = "10.20.24.36"
$IPRANGE[291] = "10.20.24.37"
$IPRANGE[292] = "10.20.24.38"
$IPRANGE[293] = "10.20.24.39"
$IPRANGE[294] = "10.20.24.40"
$IPRANGE[295] = "10.20.24.41"
$IPRANGE[296] = "10.20.24.42"
$IPRANGE[297] = "10.20.24.43"
$IPRANGE[298] = "10.20.24.44"
$IPRANGE[299] = "10.20.24.45"
$IPRANGE[300] = "10.20.24.46"
$IPRANGE[301] = "10.20.24.47"
$IPRANGE[302] = "10.20.24.48"
$IPRANGE[303] = "10.20.24.49"
$IPRANGE[304] = "10.20.24.50"
$IPRANGE[305] = "10.20.24.51"
$IPRANGE[306] = "10.20.24.52"
$IPRANGE[307] = "10.20.24.53"
$IPRANGE[308] = "10.20.24.54"
$IPRANGE[309] = "10.20.24.55"
$IPRANGE[310] = "10.20.24.56"
$IPRANGE[311] = "10.20.24.57"
$IPRANGE[312] = "10.20.24.58"
$IPRANGE[313] = "10.20.24.59"
$IPRANGE[314] = "10.20.24.60"
$IPRANGE[315] = "10.20.24.61"
$IPRANGE[316] = "10.20.24.62"
$IPRANGE[317] = "10.20.24.63"
$IPRANGE[318] = "10.20.24.64"
$IPRANGE[319] = "10.20.24.65"
$IPRANGE[320] = "10.20.24.66"
$IPRANGE[321] = "10.20.24.67"
$IPRANGE[322] = "10.20.24.68"
$IPRANGE[323] = "10.20.24.69"
$IPRANGE[324] = "10.20.24.70"
$IPRANGE[325] = "10.20.24.71"
$IPRANGE[326] = "10.20.24.72"
$IPRANGE[327] = "10.20.24.73"
$IPRANGE[328] = "10.20.24.74"
$IPRANGE[329] = "10.20.24.75"
$IPRANGE[330] = "10.20.24.76"
$IPRANGE[331] = "10.20.24.77"
$IPRANGE[332] = "10.20.24.78"
$IPRANGE[333] = "10.20.24.79"
$IPRANGE[334] = "10.20.24.80"
$IPRANGE[335] = "10.20.24.81"
$IPRANGE[336] = "10.20.24.82"
$IPRANGE[337] = "10.20.24.83"
$IPRANGE[338] = "10.20.24.84"
$IPRANGE[339] = "10.20.24.85"
$IPRANGE[340] = "10.20.24.86"
$IPRANGE[341] = "10.20.24.87"
$IPRANGE[342] = "10.20.24.88"
$IPRANGE[343] = "10.20.24.89"
$IPRANGE[344] = "10.20.24.90"
$IPRANGE[345] = "10.20.24.91"
$IPRANGE[346] = "10.20.24.92"
$IPRANGE[347] = "10.20.24.93"
$IPRANGE[348] = "10.20.24.94"
$IPRANGE[349] = "10.20.24.95"
$IPRANGE[350] = "10.20.24.96"
$IPRANGE[351] = "10.20.24.97"
$IPRANGE[352] = "10.20.24.98"
$IPRANGE[353] = "10.20.24.99"
$IPRANGE[354] = "10.20.24.100"
$IPRANGE[355] = "10.20.24.101"
$IPRANGE[356] = "10.20.24.102"
$IPRANGE[357] = "10.20.24.103"
$IPRANGE[358] = "10.20.24.104"
$IPRANGE[359] = "10.20.24.105"
$IPRANGE[360] = "10.20.24.106"
$IPRANGE[361] = "10.20.24.107"
$IPRANGE[362] = "10.20.24.108"
$IPRANGE[363] = "10.20.24.109"
$IPRANGE[364] = "10.20.24.110"
$IPRANGE[365] = "10.20.24.111"
$IPRANGE[366] = "10.20.24.112"
$IPRANGE[367] = "10.20.24.113"
$IPRANGE[368] = "10.20.24.114"
$IPRANGE[369] = "10.20.24.115"
$IPRANGE[370] = "10.20.24.116"
$IPRANGE[371] = "10.20.24.117"
$IPRANGE[372] = "10.20.24.118"
$IPRANGE[373] = "10.20.24.119"
$IPRANGE[374] = "10.20.24.120"
$IPRANGE[375] = "10.20.24.121"
$IPRANGE[376] = "10.20.24.122"
$IPRANGE[377] = "10.20.24.123"
$IPRANGE[378] = "10.20.24.124"
$IPRANGE[379] = "10.20.24.125"
$IPRANGE[380] = "10.20.24.126"
$IPRANGE[381] = "10.20.24.127"
$IPRANGE[382] = "10.20.24.128"
$IPRANGE[383] = "10.20.24.129"
$IPRANGE[384] = "10.20.24.130"
$IPRANGE[385] = "10.20.24.131"
$IPRANGE[386] = "10.20.24.132"
$IPRANGE[387] = "10.20.24.133"
$IPRANGE[388] = "10.20.24.134"
$IPRANGE[389] = "10.20.24.135"
$IPRANGE[390] = "10.20.24.136"
$IPRANGE[391] = "10.20.24.137"
$IPRANGE[392] = "10.20.24.138"
$IPRANGE[393] = "10.20.24.139"
$IPRANGE[394] = "10.20.24.140"
$IPRANGE[395] = "10.20.24.141"
$IPRANGE[396] = "10.20.24.142"
$IPRANGE[397] = "10.20.24.143"
$IPRANGE[398] = "10.20.24.144"
$IPRANGE[399] = "10.20.24.145"
$IPRANGE[400] = "10.20.24.146"
$IPRANGE[401] = "10.20.24.147"
$IPRANGE[402] = "10.20.24.148"
$IPRANGE[403] = "10.20.24.149"
$IPRANGE[404] = "10.20.24.150"
$IPRANGE[405] = "10.20.24.151"
$IPRANGE[406] = "10.20.24.152"
$IPRANGE[407] = "10.20.24.153"
$IPRANGE[408] = "10.20.24.154"
$IPRANGE[409] = "10.20.24.155"
$IPRANGE[410] = "10.20.24.156"
$IPRANGE[411] = "10.20.24.157"
$IPRANGE[412] = "10.20.24.158"
$IPRANGE[413] = "10.20.24.159"
$IPRANGE[414] = "10.20.24.160"
$IPRANGE[415] = "10.20.24.161"
$IPRANGE[416] = "10.20.24.162"
$IPRANGE[417] = "10.20.24.163"
$IPRANGE[418] = "10.20.24.164"
$IPRANGE[419] = "10.20.24.165"
$IPRANGE[420] = "10.20.24.166"
$IPRANGE[421] = "10.20.24.167"
$IPRANGE[422] = "10.20.24.168"
$IPRANGE[423] = "10.20.24.169"
$IPRANGE[424] = "10.20.24.170"
$IPRANGE[425] = "10.20.24.171"
$IPRANGE[426] = "10.20.24.172"
$IPRANGE[427] = "10.20.24.173"
$IPRANGE[428] = "10.20.24.174"
$IPRANGE[429] = "10.20.24.175"
$IPRANGE[430] = "10.20.24.176"
$IPRANGE[431] = "10.20.24.177"
$IPRANGE[432] = "10.20.24.178"
$IPRANGE[433] = "10.20.24.179"
$IPRANGE[434] = "10.20.24.180"
$IPRANGE[435] = "10.20.24.181"
$IPRANGE[436] = "10.20.24.182"
$IPRANGE[437] = "10.20.24.183"
$IPRANGE[438] = "10.20.24.184"
$IPRANGE[439] = "10.20.24.185"
$IPRANGE[440] = "10.20.24.186"
$IPRANGE[441] = "10.20.24.187"
$IPRANGE[442] = "10.20.24.188"
$IPRANGE[443] = "10.20.24.189"
$IPRANGE[444] = "10.20.24.190"
$IPRANGE[445] = "10.20.24.191"
$IPRANGE[446] = "10.20.24.192"
$IPRANGE[447] = "10.20.24.193"
$IPRANGE[448] = "10.20.24.194"
$IPRANGE[449] = "10.20.24.195"
$IPRANGE[450] = "10.20.24.196"
$IPRANGE[451] = "10.20.24.197"
$IPRANGE[452] = "10.20.24.198"
$IPRANGE[453] = "10.20.24.199"
$IPRANGE[454] = "10.20.24.200"
$IPRANGE[455] = "10.20.24.201"
$IPRANGE[456] = "10.20.24.202"
$IPRANGE[457] = "10.20.24.203"
$IPRANGE[458] = "10.20.24.204"
$IPRANGE[459] = "10.20.24.205"
$IPRANGE[460] = "10.20.24.206"
$IPRANGE[461] = "10.20.24.207"
$IPRANGE[462] = "10.20.24.208"
$IPRANGE[463] = "10.20.24.209"
$IPRANGE[464] = "10.20.24.210"
$IPRANGE[465] = "10.20.24.211"
$IPRANGE[466] = "10.20.24.212"
$IPRANGE[467] = "10.20.24.213"
$IPRANGE[468] = "10.20.24.214"
$IPRANGE[469] = "10.20.24.215"
$IPRANGE[470] = "10.20.24.216"
$IPRANGE[471] = "10.20.24.217"
$IPRANGE[472] = "10.20.24.218"
$IPRANGE[473] = "10.20.24.219"
$IPRANGE[474] = "10.20.24.220"
$IPRANGE[475] = "10.20.24.221"
$IPRANGE[476] = "10.20.24.222"
$IPRANGE[477] = "10.20.24.223"
$IPRANGE[478] = "10.20.24.224"
$IPRANGE[479] = "10.20.24.225"
$IPRANGE[480] = "10.20.24.226"
$IPRANGE[481] = "10.20.24.227"
$IPRANGE[482] = "10.20.24.228"
$IPRANGE[483] = "10.20.24.229"
$IPRANGE[484] = "10.20.24.230"
$IPRANGE[485] = "10.20.24.231"
$IPRANGE[486] = "10.20.24.232"
$IPRANGE[487] = "10.20.24.233"
$IPRANGE[488] = "10.20.24.234"
$IPRANGE[489] = "10.20.24.235"
$IPRANGE[490] = "10.20.24.236"
$IPRANGE[491] = "10.20.24.237"
$IPRANGE[492] = "10.20.24.238"
$IPRANGE[493] = "10.20.24.239"
$IPRANGE[494] = "10.20.24.240"
$IPRANGE[495] = "10.20.24.241"
$IPRANGE[496] = "10.20.24.242"
$IPRANGE[497] = "10.20.24.243"
$IPRANGE[498] = "10.20.24.244"
$IPRANGE[499] = "10.20.24.245"
$IPRANGE[500] = "10.20.24.246"
$IPRANGE[501] = "10.20.24.247"
$IPRANGE[502] = "10.20.24.248"
$IPRANGE[503] = "10.20.24.249"
$IPRANGE[504] = "10.20.24.250"
$IPRANGE[505] = "10.20.24.251"
$IPRANGE[506] = "10.20.24.252"
$IPRANGE[507] = "10.20.24.253"
$IPRANGE[508] = "10.20.24.254"
;$IPRANGE[509] = "10.20.32.103"  ;Testing only

Local $ip1
Local $ip2
Local $ip3
Local $ip4


For $i = 1 To UBound($IPRANGE) - 1
    If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then
        Call("_FileWriteLog")
     EndIf
Next


Dim $sLogPath = 'c:\windows\' & @ComputerName & ".txt"
Dim $sLogMsg = "User: "

_FileWriteLog($sLogPath, $sLogMsg)

Func _FileWriteLog($sLogPath, $sLogMsg)

Local $sDateNow
Local $sTimeNow
Local $sMsg
Local $hOpenFile
Local $hWriteFile
Local $user
Local $cname

$sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY
$sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC

$ip1 = @IPAddress1
$ip2 = @IPAddress2
$ip3 = @IPAddress3
$ip4 = @IPAddress4

$user = @UserName
$cname = @ComputerName
$osversion = @OSVersion


$sMsg = $sDateNow & "," & $cname & "," & $osversion & "," & $user & "," & $ip1 & "," & $ip2 & "," & $ip3 & "," & $ip4

$hOpenFile = FileOpen($sLogPath, 1)

If $hOpenFile = -1 Then
SetError(1)
Return 0
EndIf

$hWriteFile = FileWriteLine($hOpenFile, $sMsg)

If $hWriteFile = -1 Then
SetError(2)
Return 0
EndIf

FileClose($hOpenFile)
Return 1
EndFunc

FileCopy('c:\windows\' & @ComputerName & ".txt", '\\lon-srv2\logs',1)
Link to comment
Share on other sites

  • Solution

 In your script, after the If statement, it moved on to the next few lines  which declare the log name, path, and contents, and then run _FileWriteLog (that is why it would build even if there were no matches).   Then you attempt to declare the built in _FileWriteLog as your own function and that's just wrong.

Global $IPRANGE[509]
$IPRANGE[1] = "10.20.1.1"
$IPRANGE[2] = "10.10.1.2"
$IPRANGE[3] = "10.20.1.3"
$IPRANGE[4] = "10.20.1.4"
$IPRANGE[5] = "10.20.1.5"
$IPRANGE[6] = "10.20.1.6"
$IPRANGE[7] = "10.20.1.7"
$IPRANGE[8] = "10.20.1.8"
$IPRANGE[9] = "10.20.1.9"
$IPRANGE[10] = "10.20.1.10"
$IPRANGE[11] = "10.20.1.11"
$IPRANGE[12] = "10.20.1.12"
$IPRANGE[13] = "10.20.1.13"
$IPRANGE[14] = "10.20.1.14"
$IPRANGE[15] = "10.20.1.15"
$IPRANGE[16] = "10.20.1.16"
$IPRANGE[17] = "10.20.1.17"
$IPRANGE[18] = "10.20.1.18"
$IPRANGE[19] = "10.20.1.19"
$IPRANGE[20] = "10.20.1.20"
$IPRANGE[21] = "10.20.1.21"
$IPRANGE[22] = "10.20.1.22"
$IPRANGE[23] = "10.20.1.23"
$IPRANGE[24] = "10.20.1.24"
$IPRANGE[25] = "10.20.1.25"
$IPRANGE[26] = "10.20.1.26"
$IPRANGE[27] = "10.20.1.27"
$IPRANGE[28] = "10.20.1.28"
$IPRANGE[29] = "10.20.1.29"
$IPRANGE[30] = "10.20.1.30"
$IPRANGE[31] = "10.20.1.31"
$IPRANGE[32] = "10.20.1.32"
$IPRANGE[33] = "10.20.1.33"
$IPRANGE[34] = "10.20.1.34"
$IPRANGE[35] = "10.20.1.35"
$IPRANGE[36] = "10.20.1.36"
$IPRANGE[37] = "10.20.1.37"
$IPRANGE[38] = "10.20.1.38"
$IPRANGE[39] = "10.20.1.39"
$IPRANGE[40] = "10.20.1.40"
$IPRANGE[41] = "10.20.1.41"
$IPRANGE[42] = "10.20.1.42"
$IPRANGE[43] = "10.20.1.43"
$IPRANGE[44] = "10.20.1.44"
$IPRANGE[45] = "10.20.1.45"
$IPRANGE[46] = "10.20.1.46"
$IPRANGE[47] = "10.20.1.47"
$IPRANGE[48] = "10.20.1.48"
$IPRANGE[49] = "10.20.1.49"
$IPRANGE[50] = "10.20.1.50"
$IPRANGE[51] = "10.20.1.51"
$IPRANGE[52] = "10.20.1.52"
$IPRANGE[53] = "10.20.1.53"
$IPRANGE[54] = "10.20.1.54"
$IPRANGE[55] = "10.20.1.55"
$IPRANGE[56] = "10.20.1.56"
$IPRANGE[57] = "10.20.1.57"
$IPRANGE[58] = "10.20.1.58"
$IPRANGE[59] = "10.20.1.59"
$IPRANGE[60] = "10.20.1.60"
$IPRANGE[61] = "10.20.1.61"
$IPRANGE[62] = "10.20.1.62"
$IPRANGE[63] = "10.20.1.63"
$IPRANGE[64] = "10.20.1.64"
$IPRANGE[65] = "10.20.1.65"
$IPRANGE[66] = "10.20.1.66"
$IPRANGE[67] = "10.20.1.67"
$IPRANGE[68] = "10.20.1.68"
$IPRANGE[69] = "10.20.1.69"
$IPRANGE[70] = "10.20.1.70"
$IPRANGE[71] = "10.20.1.71"
$IPRANGE[72] = "10.20.1.72"
$IPRANGE[73] = "10.20.1.73"
$IPRANGE[74] = "10.20.1.74"
$IPRANGE[75] = "10.20.1.75"
$IPRANGE[76] = "10.20.1.76"
$IPRANGE[77] = "10.20.1.77"
$IPRANGE[78] = "10.20.1.78"
$IPRANGE[79] = "10.20.1.79"
$IPRANGE[80] = "10.20.1.80"
$IPRANGE[81] = "10.20.1.81"
$IPRANGE[82] = "10.20.1.82"
$IPRANGE[83] = "10.20.1.83"
$IPRANGE[84] = "10.20.1.84"
$IPRANGE[85] = "10.20.1.85"
$IPRANGE[86] = "10.20.1.86"
$IPRANGE[87] = "10.20.1.87"
$IPRANGE[88] = "10.20.1.88"
$IPRANGE[89] = "10.20.1.89"
$IPRANGE[90] = "10.20.1.90"
$IPRANGE[91] = "10.20.1.91"
$IPRANGE[92] = "10.20.1.92"
$IPRANGE[93] = "10.20.1.93"
$IPRANGE[94] = "10.20.1.94"
$IPRANGE[95] = "10.20.1.95"
$IPRANGE[96] = "10.20.1.96"
$IPRANGE[97] = "10.20.1.97"
$IPRANGE[98] = "10.20.1.98"
$IPRANGE[99] = "10.20.1.99"
$IPRANGE[100] = "10.20.1.100"
$IPRANGE[101] = "10.20.1.101"
$IPRANGE[102] = "10.20.1.102"
$IPRANGE[103] = "10.20.1.103"
$IPRANGE[104] = "10.20.1.104"
$IPRANGE[105] = "10.20.1.105"
$IPRANGE[106] = "10.20.1.106"
$IPRANGE[107] = "10.20.1.107"
$IPRANGE[108] = "10.20.1.108"
$IPRANGE[109] = "10.20.1.109"
$IPRANGE[110] = "10.20.1.110"
$IPRANGE[111] = "10.20.1.111"
$IPRANGE[112] = "10.20.1.112"
$IPRANGE[113] = "10.20.1.113"
$IPRANGE[114] = "10.20.1.114"
$IPRANGE[115] = "10.20.1.115"
$IPRANGE[116] = "10.20.1.116"
$IPRANGE[117] = "10.20.1.117"
$IPRANGE[118] = "10.20.1.118"
$IPRANGE[119] = "10.20.1.119"
$IPRANGE[120] = "10.20.1.120"
$IPRANGE[121] = "10.20.1.121"
$IPRANGE[122] = "10.20.1.122"
$IPRANGE[123] = "10.20.1.123"
$IPRANGE[124] = "10.20.1.124"
$IPRANGE[125] = "10.20.1.125"
$IPRANGE[126] = "10.20.1.126"
$IPRANGE[127] = "10.20.1.127"
$IPRANGE[128] = "10.20.1.128"
$IPRANGE[129] = "10.20.1.129"
$IPRANGE[130] = "10.20.1.130"
$IPRANGE[131] = "10.20.1.131"
$IPRANGE[132] = "10.20.1.132"
$IPRANGE[133] = "10.20.1.133"
$IPRANGE[134] = "10.20.1.134"
$IPRANGE[135] = "10.20.1.135"
$IPRANGE[136] = "10.20.1.136"
$IPRANGE[137] = "10.20.1.137"
$IPRANGE[138] = "10.20.1.138"
$IPRANGE[139] = "10.20.1.139"
$IPRANGE[140] = "10.20.1.140"
$IPRANGE[141] = "10.20.1.141"
$IPRANGE[142] = "10.20.1.142"
$IPRANGE[143] = "10.20.1.143"
$IPRANGE[144] = "10.20.1.144"
$IPRANGE[145] = "10.20.1.145"
$IPRANGE[146] = "10.20.1.146"
$IPRANGE[147] = "10.20.1.147"
$IPRANGE[148] = "10.20.1.148"
$IPRANGE[149] = "10.20.1.149"
$IPRANGE[150] = "10.20.1.150"
$IPRANGE[151] = "10.20.1.151"
$IPRANGE[152] = "10.20.1.152"
$IPRANGE[153] = "10.20.1.153"
$IPRANGE[154] = "10.20.1.154"
$IPRANGE[155] = "10.20.1.155"
$IPRANGE[156] = "10.20.1.156"
$IPRANGE[157] = "10.20.1.157"
$IPRANGE[158] = "10.20.1.158"
$IPRANGE[159] = "10.20.1.159"
$IPRANGE[160] = "10.20.1.160"
$IPRANGE[161] = "10.20.1.161"
$IPRANGE[162] = "10.20.1.162"
$IPRANGE[163] = "10.20.1.163"
$IPRANGE[164] = "10.20.1.164"
$IPRANGE[165] = "10.20.1.165"
$IPRANGE[166] = "10.20.1.166"
$IPRANGE[167] = "10.20.1.167"
$IPRANGE[168] = "10.20.1.168"
$IPRANGE[169] = "10.20.1.169"
$IPRANGE[170] = "10.20.1.170"
$IPRANGE[171] = "10.20.1.171"
$IPRANGE[172] = "10.20.1.172"
$IPRANGE[173] = "10.20.1.173"
$IPRANGE[174] = "10.20.1.174"
$IPRANGE[175] = "10.20.1.175"
$IPRANGE[176] = "10.20.1.176"
$IPRANGE[177] = "10.20.1.177"
$IPRANGE[178] = "10.20.1.178"
$IPRANGE[179] = "10.20.1.179"
$IPRANGE[180] = "10.20.1.180"
$IPRANGE[181] = "10.20.1.181"
$IPRANGE[182] = "10.20.1.182"
$IPRANGE[183] = "10.20.1.183"
$IPRANGE[184] = "10.20.1.184"
$IPRANGE[185] = "10.20.1.185"
$IPRANGE[186] = "10.20.1.186"
$IPRANGE[187] = "10.20.1.187"
$IPRANGE[188] = "10.20.1.188"
$IPRANGE[189] = "10.20.1.189"
$IPRANGE[190] = "10.20.1.190"
$IPRANGE[191] = "10.20.1.191"
$IPRANGE[192] = "10.20.1.192"
$IPRANGE[193] = "10.20.1.193"
$IPRANGE[194] = "10.20.1.194"
$IPRANGE[195] = "10.20.1.195"
$IPRANGE[196] = "10.20.1.196"
$IPRANGE[197] = "10.20.1.197"
$IPRANGE[198] = "10.20.1.198"
$IPRANGE[199] = "10.20.1.199"
$IPRANGE[200] = "10.20.1.200"
$IPRANGE[201] = "10.20.1.201"
$IPRANGE[202] = "10.20.1.202"
$IPRANGE[203] = "10.20.1.203"
$IPRANGE[204] = "10.20.1.204"
$IPRANGE[205] = "10.20.1.205"
$IPRANGE[206] = "10.20.1.206"
$IPRANGE[207] = "10.20.1.207"
$IPRANGE[208] = "10.20.1.208"
$IPRANGE[209] = "10.20.1.209"
$IPRANGE[210] = "10.20.1.210"
$IPRANGE[211] = "10.20.1.211"
$IPRANGE[212] = "10.20.1.212"
$IPRANGE[213] = "10.20.1.213"
$IPRANGE[214] = "10.20.1.214"
$IPRANGE[215] = "10.20.1.215"
$IPRANGE[216] = "10.20.1.216"
$IPRANGE[217] = "10.20.1.217"
$IPRANGE[218] = "10.20.1.218"
$IPRANGE[219] = "10.20.1.219"
$IPRANGE[220] = "10.20.1.220"
$IPRANGE[221] = "10.20.1.221"
$IPRANGE[222] = "10.20.1.222"
$IPRANGE[223] = "10.20.1.223"
$IPRANGE[224] = "10.20.1.224"
$IPRANGE[225] = "10.20.1.225"
$IPRANGE[226] = "10.20.1.226"
$IPRANGE[227] = "10.20.1.227"
$IPRANGE[228] = "10.20.1.228"
$IPRANGE[229] = "10.20.1.229"
$IPRANGE[230] = "10.20.1.230"
$IPRANGE[231] = "10.20.1.231"
$IPRANGE[232] = "10.20.1.232"
$IPRANGE[233] = "10.20.1.233"
$IPRANGE[234] = "10.20.1.234"
$IPRANGE[235] = "10.20.1.235"
$IPRANGE[236] = "10.20.1.236"
$IPRANGE[237] = "10.20.1.237"
$IPRANGE[238] = "10.20.1.238"
$IPRANGE[239] = "10.20.1.239"
$IPRANGE[240] = "10.20.1.240"
$IPRANGE[241] = "10.20.1.241"
$IPRANGE[242] = "10.20.1.242"
$IPRANGE[243] = "10.20.1.243"
$IPRANGE[244] = "10.20.1.244"
$IPRANGE[245] = "10.20.1.245"
$IPRANGE[246] = "10.20.1.246"
$IPRANGE[247] = "10.20.1.247"
$IPRANGE[248] = "10.20.1.248"
$IPRANGE[249] = "10.20.1.249"
$IPRANGE[250] = "10.20.1.250"
$IPRANGE[251] = "10.20.1.251"
$IPRANGE[252] = "10.20.1.252"
$IPRANGE[253] = "10.20.1.253"
$IPRANGE[254] = "10.20.1.254"
$IPRANGE[255] = "10.20.24.1"
$IPRANGE[256] = "10.20.24.2"
$IPRANGE[257] = "10.20.24.3"
$IPRANGE[258] = "10.20.24.4"
$IPRANGE[259] = "10.20.24.5"
$IPRANGE[260] = "10.20.24.6"
$IPRANGE[261] = "10.20.24.7"
$IPRANGE[262] = "10.20.24.8"
$IPRANGE[263] = "10.20.24.9"
$IPRANGE[264] = "10.20.24.10"
$IPRANGE[265] = "10.20.24.11"
$IPRANGE[266] = "10.20.24.12"
$IPRANGE[267] = "10.20.24.13"
$IPRANGE[268] = "10.20.24.14"
$IPRANGE[269] = "10.20.24.15"
$IPRANGE[270] = "10.20.24.16"
$IPRANGE[271] = "10.20.24.17"
$IPRANGE[272] = "10.20.24.18"
$IPRANGE[273] = "10.20.24.19"
$IPRANGE[274] = "10.20.24.20"
$IPRANGE[275] = "10.20.24.21"
$IPRANGE[276] = "10.20.24.22"
$IPRANGE[277] = "10.20.24.23"
$IPRANGE[278] = "10.20.24.24"
$IPRANGE[279] = "10.20.24.25"
$IPRANGE[280] = "10.20.24.26"
$IPRANGE[281] = "10.20.24.27"
$IPRANGE[282] = "10.20.24.28"
$IPRANGE[283] = "10.20.24.29"
$IPRANGE[284] = "10.20.24.30"
$IPRANGE[285] = "10.20.24.31"
$IPRANGE[286] = "10.20.24.32"
$IPRANGE[287] = "10.20.24.33"
$IPRANGE[288] = "10.20.24.34"
$IPRANGE[289] = "10.20.24.35"
$IPRANGE[290] = "10.20.24.36"
$IPRANGE[291] = "10.20.24.37"
$IPRANGE[292] = "10.20.24.38"
$IPRANGE[293] = "10.20.24.39"
$IPRANGE[294] = "10.20.24.40"
$IPRANGE[295] = "10.20.24.41"
$IPRANGE[296] = "10.20.24.42"
$IPRANGE[297] = "10.20.24.43"
$IPRANGE[298] = "10.20.24.44"
$IPRANGE[299] = "10.20.24.45"
$IPRANGE[300] = "10.20.24.46"
$IPRANGE[301] = "10.20.24.47"
$IPRANGE[302] = "10.20.24.48"
$IPRANGE[303] = "10.20.24.49"
$IPRANGE[304] = "10.20.24.50"
$IPRANGE[305] = "10.20.24.51"
$IPRANGE[306] = "10.20.24.52"
$IPRANGE[307] = "10.20.24.53"
$IPRANGE[308] = "10.20.24.54"
$IPRANGE[309] = "10.20.24.55"
$IPRANGE[310] = "10.20.24.56"
$IPRANGE[311] = "10.20.24.57"
$IPRANGE[312] = "10.20.24.58"
$IPRANGE[313] = "10.20.24.59"
$IPRANGE[314] = "10.20.24.60"
$IPRANGE[315] = "10.20.24.61"
$IPRANGE[316] = "10.20.24.62"
$IPRANGE[317] = "10.20.24.63"
$IPRANGE[318] = "10.20.24.64"
$IPRANGE[319] = "10.20.24.65"
$IPRANGE[320] = "10.20.24.66"
$IPRANGE[321] = "10.20.24.67"
$IPRANGE[322] = "10.20.24.68"
$IPRANGE[323] = "10.20.24.69"
$IPRANGE[324] = "10.20.24.70"
$IPRANGE[325] = "10.20.24.71"
$IPRANGE[326] = "10.20.24.72"
$IPRANGE[327] = "10.20.24.73"
$IPRANGE[328] = "10.20.24.74"
$IPRANGE[329] = "10.20.24.75"
$IPRANGE[330] = "10.20.24.76"
$IPRANGE[331] = "10.20.24.77"
$IPRANGE[332] = "10.20.24.78"
$IPRANGE[333] = "10.20.24.79"
$IPRANGE[334] = "10.20.24.80"
$IPRANGE[335] = "10.20.24.81"
$IPRANGE[336] = "10.20.24.82"
$IPRANGE[337] = "10.20.24.83"
$IPRANGE[338] = "10.20.24.84"
$IPRANGE[339] = "10.20.24.85"
$IPRANGE[340] = "10.20.24.86"
$IPRANGE[341] = "10.20.24.87"
$IPRANGE[342] = "10.20.24.88"
$IPRANGE[343] = "10.20.24.89"
$IPRANGE[344] = "10.20.24.90"
$IPRANGE[345] = "10.20.24.91"
$IPRANGE[346] = "10.20.24.92"
$IPRANGE[347] = "10.20.24.93"
$IPRANGE[348] = "10.20.24.94"
$IPRANGE[349] = "10.20.24.95"
$IPRANGE[350] = "10.20.24.96"
$IPRANGE[351] = "10.20.24.97"
$IPRANGE[352] = "10.20.24.98"
$IPRANGE[353] = "10.20.24.99"
$IPRANGE[354] = "10.20.24.100"
$IPRANGE[355] = "10.20.24.101"
$IPRANGE[356] = "10.20.24.102"
$IPRANGE[357] = "10.20.24.103"
$IPRANGE[358] = "10.20.24.104"
$IPRANGE[359] = "10.20.24.105"
$IPRANGE[360] = "10.20.24.106"
$IPRANGE[361] = "10.20.24.107"
$IPRANGE[362] = "10.20.24.108"
$IPRANGE[363] = "10.20.24.109"
$IPRANGE[364] = "10.20.24.110"
$IPRANGE[365] = "10.20.24.111"
$IPRANGE[366] = "10.20.24.112"
$IPRANGE[367] = "10.20.24.113"
$IPRANGE[368] = "10.20.24.114"
$IPRANGE[369] = "10.20.24.115"
$IPRANGE[370] = "10.20.24.116"
$IPRANGE[371] = "10.20.24.117"
$IPRANGE[372] = "10.20.24.118"
$IPRANGE[373] = "10.20.24.119"
$IPRANGE[374] = "10.20.24.120"
$IPRANGE[375] = "10.20.24.121"
$IPRANGE[376] = "10.20.24.122"
$IPRANGE[377] = "10.20.24.123"
$IPRANGE[378] = "10.20.24.124"
$IPRANGE[379] = "10.20.24.125"
$IPRANGE[380] = "10.20.24.126"
$IPRANGE[381] = "10.20.24.127"
$IPRANGE[382] = "10.20.24.128"
$IPRANGE[383] = "10.20.24.129"
$IPRANGE[384] = "10.20.24.130"
$IPRANGE[385] = "10.20.24.131"
$IPRANGE[386] = "10.20.24.132"
$IPRANGE[387] = "10.20.24.133"
$IPRANGE[388] = "10.20.24.134"
$IPRANGE[389] = "10.20.24.135"
$IPRANGE[390] = "10.20.24.136"
$IPRANGE[391] = "10.20.24.137"
$IPRANGE[392] = "10.20.24.138"
$IPRANGE[393] = "10.20.24.139"
$IPRANGE[394] = "10.20.24.140"
$IPRANGE[395] = "10.20.24.141"
$IPRANGE[396] = "10.20.24.142"
$IPRANGE[397] = "10.20.24.143"
$IPRANGE[398] = "10.20.24.144"
$IPRANGE[399] = "10.20.24.145"
$IPRANGE[400] = "10.20.24.146"
$IPRANGE[401] = "10.20.24.147"
$IPRANGE[402] = "10.20.24.148"
$IPRANGE[403] = "10.20.24.149"
$IPRANGE[404] = "10.20.24.150"
$IPRANGE[405] = "10.20.24.151"
$IPRANGE[406] = "10.20.24.152"
$IPRANGE[407] = "10.20.24.153"
$IPRANGE[408] = "10.20.24.154"
$IPRANGE[409] = "10.20.24.155"
$IPRANGE[410] = "10.20.24.156"
$IPRANGE[411] = "10.20.24.157"
$IPRANGE[412] = "10.20.24.158"
$IPRANGE[413] = "10.20.24.159"
$IPRANGE[414] = "10.20.24.160"
$IPRANGE[415] = "10.20.24.161"
$IPRANGE[416] = "10.20.24.162"
$IPRANGE[417] = "10.20.24.163"
$IPRANGE[418] = "10.20.24.164"
$IPRANGE[419] = "10.20.24.165"
$IPRANGE[420] = "10.20.24.166"
$IPRANGE[421] = "10.20.24.167"
$IPRANGE[422] = "10.20.24.168"
$IPRANGE[423] = "10.20.24.169"
$IPRANGE[424] = "10.20.24.170"
$IPRANGE[425] = "10.20.24.171"
$IPRANGE[426] = "10.20.24.172"
$IPRANGE[427] = "10.20.24.173"
$IPRANGE[428] = "10.20.24.174"
$IPRANGE[429] = "10.20.24.175"
$IPRANGE[430] = "10.20.24.176"
$IPRANGE[431] = "10.20.24.177"
$IPRANGE[432] = "10.20.24.178"
$IPRANGE[433] = "10.20.24.179"
$IPRANGE[434] = "10.20.24.180"
$IPRANGE[435] = "10.20.24.181"
$IPRANGE[436] = "10.20.24.182"
$IPRANGE[437] = "10.20.24.183"
$IPRANGE[438] = "10.20.24.184"
$IPRANGE[439] = "10.20.24.185"
$IPRANGE[440] = "10.20.24.186"
$IPRANGE[441] = "10.20.24.187"
$IPRANGE[442] = "10.20.24.188"
$IPRANGE[443] = "10.20.24.189"
$IPRANGE[444] = "10.20.24.190"
$IPRANGE[445] = "10.20.24.191"
$IPRANGE[446] = "10.20.24.192"
$IPRANGE[447] = "10.20.24.193"
$IPRANGE[448] = "10.20.24.194"
$IPRANGE[449] = "10.20.24.195"
$IPRANGE[450] = "10.20.24.196"
$IPRANGE[451] = "10.20.24.197"
$IPRANGE[452] = "10.20.24.198"
$IPRANGE[453] = "10.20.24.199"
$IPRANGE[454] = "10.20.24.200"
$IPRANGE[455] = "10.20.24.201"
$IPRANGE[456] = "10.20.24.202"
$IPRANGE[457] = "10.20.24.203"
$IPRANGE[458] = "10.20.24.204"
$IPRANGE[459] = "10.20.24.205"
$IPRANGE[460] = "10.20.24.206"
$IPRANGE[461] = "10.20.24.207"
$IPRANGE[462] = "10.20.24.208"
$IPRANGE[463] = "10.20.24.209"
$IPRANGE[464] = "10.20.24.210"
$IPRANGE[465] = "10.20.24.211"
$IPRANGE[466] = "10.20.24.212"
$IPRANGE[467] = "10.20.24.213"
$IPRANGE[468] = "10.20.24.214"
$IPRANGE[469] = "10.20.24.215"
$IPRANGE[470] = "10.20.24.216"
$IPRANGE[471] = "10.20.24.217"
$IPRANGE[472] = "10.20.24.218"
$IPRANGE[473] = "10.20.24.219"
$IPRANGE[474] = "10.20.24.220"
$IPRANGE[475] = "10.20.24.221"
$IPRANGE[476] = "10.20.24.222"
$IPRANGE[477] = "10.20.24.223"
$IPRANGE[478] = "10.20.24.224"
$IPRANGE[479] = "10.20.24.225"
$IPRANGE[480] = "10.20.24.226"
$IPRANGE[481] = "10.20.24.227"
$IPRANGE[482] = "10.20.24.228"
$IPRANGE[483] = "10.20.24.229"
$IPRANGE[484] = "10.20.24.230"
$IPRANGE[485] = "10.20.24.231"
$IPRANGE[486] = "10.20.24.232"
$IPRANGE[487] = "10.20.24.233"
$IPRANGE[488] = "10.20.24.234"
$IPRANGE[489] = "10.20.24.235"
$IPRANGE[490] = "10.20.24.236"
$IPRANGE[491] = "10.20.24.237"
$IPRANGE[492] = "10.20.24.238"
$IPRANGE[493] = "10.20.24.239"
$IPRANGE[494] = "10.20.24.240"
$IPRANGE[495] = "10.20.24.241"
$IPRANGE[496] = "10.20.24.242"
$IPRANGE[497] = "10.20.24.243"
$IPRANGE[498] = "10.20.24.244"
$IPRANGE[499] = "10.20.24.245"
$IPRANGE[500] = "10.20.24.246"
$IPRANGE[501] = "10.20.24.247"
$IPRANGE[502] = "10.20.24.248"
$IPRANGE[503] = "10.20.24.249"
$IPRANGE[504] = "10.20.24.250"
$IPRANGE[505] = "10.20.24.251"
$IPRANGE[506] = "10.20.24.252"
$IPRANGE[507] = "10.20.24.253"
$IPRANGE[508] = "10.20.24.254"
;$IPRANGE[509] = "10.20.32.103"  ;Testing only

Local $ip1
Local $ip2
Local $ip3
Local $ip4

Dim $sLogPath = @ScriptDir & "\TESTIPLOG.txt"
Dim $sLogMsg = "User: "

For $i = 1 To UBound($IPRANGE) - 1
    If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then
        _MyFileWriteLog($sLogPath , $sLogMsg)
     EndIf
Next


Func _MyFileWriteLog($sLogPath, $sLogMsg)

Local $sDateNow
Local $sTimeNow
Local $sMsg
Local $hOpenFile
Local $hWriteFile
Local $user
Local $cname

$sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY
$sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC

$ip1 = @IPAddress1
$ip2 = @IPAddress2
$ip3 = @IPAddress3
$ip4 = @IPAddress4

$user = @UserName
$cname = @ComputerName
$osversion = @OSVersion


$sMsg = $sDateNow & "," & $cname & "," & $osversion & "," & $user & "," & $ip1 & "," & $ip2 & "," & $ip3 & "," & $ip4

$hOpenFile = FileOpen($sLogPath, 1)

If $hOpenFile = -1 Then
SetError(1)
Return 0
EndIf

$hWriteFile = FileWriteLine($hOpenFile, $sMsg)

If $hWriteFile = -1 Then
SetError(2)
Return 0
EndIf

FileClose($hOpenFile)
Return 1
EndFunc

FileCopy('c:\windows\' & @ComputerName & ".txt", '\\lon-srv2\logs',1)
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Well I'm totally confused now - I thought I would get around this by adding a stupid Exit function however the script now runs and exits, even when the TEST IP is supposed to be logged. I'm really pissing in the wind with this now.

For $i = 1 To UBound($IPRANGE) - 1
    If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then
        Call("_FileWriteLog")
    Else
        Call("BYE")
        EndIf
Next

Func BYE()
    Exit
EndFunc
Link to comment
Share on other sites

 

 In your script, after the If statement, it moved on to the next few lines  which declare the log name, path, and contents, and then run _FileWriteLog (that is why it would build even if there were no matches).   Then you attempt to declare the built in _FileWriteLog as your own function and that's just wrong.

Global $IPRANGE[509]
$IPRANGE[1] = "10.20.1.1"
$IPRANGE[2] = "10.10.1.2"
$IPRANGE[3] = "10.20.1.3"
$IPRANGE[4] = "10.20.1.4"
$IPRANGE[5] = "10.20.1.5"
$IPRANGE[6] = "10.20.1.6"
$IPRANGE[7] = "10.20.1.7"
$IPRANGE[8] = "10.20.1.8"
$IPRANGE[9] = "10.20.1.9"
$IPRANGE[10] = "10.20.1.10"
$IPRANGE[11] = "10.20.1.11"
$IPRANGE[12] = "10.20.1.12"
$IPRANGE[13] = "10.20.1.13"
$IPRANGE[14] = "10.20.1.14"
$IPRANGE[15] = "10.20.1.15"
$IPRANGE[16] = "10.20.1.16"
$IPRANGE[17] = "10.20.1.17"
$IPRANGE[18] = "10.20.1.18"
$IPRANGE[19] = "10.20.1.19"
$IPRANGE[20] = "10.20.1.20"
$IPRANGE[21] = "10.20.1.21"
$IPRANGE[22] = "10.20.1.22"
$IPRANGE[23] = "10.20.1.23"
$IPRANGE[24] = "10.20.1.24"
$IPRANGE[25] = "10.20.1.25"
$IPRANGE[26] = "10.20.1.26"
$IPRANGE[27] = "10.20.1.27"
$IPRANGE[28] = "10.20.1.28"
$IPRANGE[29] = "10.20.1.29"
$IPRANGE[30] = "10.20.1.30"
$IPRANGE[31] = "10.20.1.31"
$IPRANGE[32] = "10.20.1.32"
$IPRANGE[33] = "10.20.1.33"
$IPRANGE[34] = "10.20.1.34"
$IPRANGE[35] = "10.20.1.35"
$IPRANGE[36] = "10.20.1.36"
$IPRANGE[37] = "10.20.1.37"
$IPRANGE[38] = "10.20.1.38"
$IPRANGE[39] = "10.20.1.39"
$IPRANGE[40] = "10.20.1.40"
$IPRANGE[41] = "10.20.1.41"
$IPRANGE[42] = "10.20.1.42"
$IPRANGE[43] = "10.20.1.43"
$IPRANGE[44] = "10.20.1.44"
$IPRANGE[45] = "10.20.1.45"
$IPRANGE[46] = "10.20.1.46"
$IPRANGE[47] = "10.20.1.47"
$IPRANGE[48] = "10.20.1.48"
$IPRANGE[49] = "10.20.1.49"
$IPRANGE[50] = "10.20.1.50"
$IPRANGE[51] = "10.20.1.51"
$IPRANGE[52] = "10.20.1.52"
$IPRANGE[53] = "10.20.1.53"
$IPRANGE[54] = "10.20.1.54"
$IPRANGE[55] = "10.20.1.55"
$IPRANGE[56] = "10.20.1.56"
$IPRANGE[57] = "10.20.1.57"
$IPRANGE[58] = "10.20.1.58"
$IPRANGE[59] = "10.20.1.59"
$IPRANGE[60] = "10.20.1.60"
$IPRANGE[61] = "10.20.1.61"
$IPRANGE[62] = "10.20.1.62"
$IPRANGE[63] = "10.20.1.63"
$IPRANGE[64] = "10.20.1.64"
$IPRANGE[65] = "10.20.1.65"
$IPRANGE[66] = "10.20.1.66"
$IPRANGE[67] = "10.20.1.67"
$IPRANGE[68] = "10.20.1.68"
$IPRANGE[69] = "10.20.1.69"
$IPRANGE[70] = "10.20.1.70"
$IPRANGE[71] = "10.20.1.71"
$IPRANGE[72] = "10.20.1.72"
$IPRANGE[73] = "10.20.1.73"
$IPRANGE[74] = "10.20.1.74"
$IPRANGE[75] = "10.20.1.75"
$IPRANGE[76] = "10.20.1.76"
$IPRANGE[77] = "10.20.1.77"
$IPRANGE[78] = "10.20.1.78"
$IPRANGE[79] = "10.20.1.79"
$IPRANGE[80] = "10.20.1.80"
$IPRANGE[81] = "10.20.1.81"
$IPRANGE[82] = "10.20.1.82"
$IPRANGE[83] = "10.20.1.83"
$IPRANGE[84] = "10.20.1.84"
$IPRANGE[85] = "10.20.1.85"
$IPRANGE[86] = "10.20.1.86"
$IPRANGE[87] = "10.20.1.87"
$IPRANGE[88] = "10.20.1.88"
$IPRANGE[89] = "10.20.1.89"
$IPRANGE[90] = "10.20.1.90"
$IPRANGE[91] = "10.20.1.91"
$IPRANGE[92] = "10.20.1.92"
$IPRANGE[93] = "10.20.1.93"
$IPRANGE[94] = "10.20.1.94"
$IPRANGE[95] = "10.20.1.95"
$IPRANGE[96] = "10.20.1.96"
$IPRANGE[97] = "10.20.1.97"
$IPRANGE[98] = "10.20.1.98"
$IPRANGE[99] = "10.20.1.99"
$IPRANGE[100] = "10.20.1.100"
$IPRANGE[101] = "10.20.1.101"
$IPRANGE[102] = "10.20.1.102"
$IPRANGE[103] = "10.20.1.103"
$IPRANGE[104] = "10.20.1.104"
$IPRANGE[105] = "10.20.1.105"
$IPRANGE[106] = "10.20.1.106"
$IPRANGE[107] = "10.20.1.107"
$IPRANGE[108] = "10.20.1.108"
$IPRANGE[109] = "10.20.1.109"
$IPRANGE[110] = "10.20.1.110"
$IPRANGE[111] = "10.20.1.111"
$IPRANGE[112] = "10.20.1.112"
$IPRANGE[113] = "10.20.1.113"
$IPRANGE[114] = "10.20.1.114"
$IPRANGE[115] = "10.20.1.115"
$IPRANGE[116] = "10.20.1.116"
$IPRANGE[117] = "10.20.1.117"
$IPRANGE[118] = "10.20.1.118"
$IPRANGE[119] = "10.20.1.119"
$IPRANGE[120] = "10.20.1.120"
$IPRANGE[121] = "10.20.1.121"
$IPRANGE[122] = "10.20.1.122"
$IPRANGE[123] = "10.20.1.123"
$IPRANGE[124] = "10.20.1.124"
$IPRANGE[125] = "10.20.1.125"
$IPRANGE[126] = "10.20.1.126"
$IPRANGE[127] = "10.20.1.127"
$IPRANGE[128] = "10.20.1.128"
$IPRANGE[129] = "10.20.1.129"
$IPRANGE[130] = "10.20.1.130"
$IPRANGE[131] = "10.20.1.131"
$IPRANGE[132] = "10.20.1.132"
$IPRANGE[133] = "10.20.1.133"
$IPRANGE[134] = "10.20.1.134"
$IPRANGE[135] = "10.20.1.135"
$IPRANGE[136] = "10.20.1.136"
$IPRANGE[137] = "10.20.1.137"
$IPRANGE[138] = "10.20.1.138"
$IPRANGE[139] = "10.20.1.139"
$IPRANGE[140] = "10.20.1.140"
$IPRANGE[141] = "10.20.1.141"
$IPRANGE[142] = "10.20.1.142"
$IPRANGE[143] = "10.20.1.143"
$IPRANGE[144] = "10.20.1.144"
$IPRANGE[145] = "10.20.1.145"
$IPRANGE[146] = "10.20.1.146"
$IPRANGE[147] = "10.20.1.147"
$IPRANGE[148] = "10.20.1.148"
$IPRANGE[149] = "10.20.1.149"
$IPRANGE[150] = "10.20.1.150"
$IPRANGE[151] = "10.20.1.151"
$IPRANGE[152] = "10.20.1.152"
$IPRANGE[153] = "10.20.1.153"
$IPRANGE[154] = "10.20.1.154"
$IPRANGE[155] = "10.20.1.155"
$IPRANGE[156] = "10.20.1.156"
$IPRANGE[157] = "10.20.1.157"
$IPRANGE[158] = "10.20.1.158"
$IPRANGE[159] = "10.20.1.159"
$IPRANGE[160] = "10.20.1.160"
$IPRANGE[161] = "10.20.1.161"
$IPRANGE[162] = "10.20.1.162"
$IPRANGE[163] = "10.20.1.163"
$IPRANGE[164] = "10.20.1.164"
$IPRANGE[165] = "10.20.1.165"
$IPRANGE[166] = "10.20.1.166"
$IPRANGE[167] = "10.20.1.167"
$IPRANGE[168] = "10.20.1.168"
$IPRANGE[169] = "10.20.1.169"
$IPRANGE[170] = "10.20.1.170"
$IPRANGE[171] = "10.20.1.171"
$IPRANGE[172] = "10.20.1.172"
$IPRANGE[173] = "10.20.1.173"
$IPRANGE[174] = "10.20.1.174"
$IPRANGE[175] = "10.20.1.175"
$IPRANGE[176] = "10.20.1.176"
$IPRANGE[177] = "10.20.1.177"
$IPRANGE[178] = "10.20.1.178"
$IPRANGE[179] = "10.20.1.179"
$IPRANGE[180] = "10.20.1.180"
$IPRANGE[181] = "10.20.1.181"
$IPRANGE[182] = "10.20.1.182"
$IPRANGE[183] = "10.20.1.183"
$IPRANGE[184] = "10.20.1.184"
$IPRANGE[185] = "10.20.1.185"
$IPRANGE[186] = "10.20.1.186"
$IPRANGE[187] = "10.20.1.187"
$IPRANGE[188] = "10.20.1.188"
$IPRANGE[189] = "10.20.1.189"
$IPRANGE[190] = "10.20.1.190"
$IPRANGE[191] = "10.20.1.191"
$IPRANGE[192] = "10.20.1.192"
$IPRANGE[193] = "10.20.1.193"
$IPRANGE[194] = "10.20.1.194"
$IPRANGE[195] = "10.20.1.195"
$IPRANGE[196] = "10.20.1.196"
$IPRANGE[197] = "10.20.1.197"
$IPRANGE[198] = "10.20.1.198"
$IPRANGE[199] = "10.20.1.199"
$IPRANGE[200] = "10.20.1.200"
$IPRANGE[201] = "10.20.1.201"
$IPRANGE[202] = "10.20.1.202"
$IPRANGE[203] = "10.20.1.203"
$IPRANGE[204] = "10.20.1.204"
$IPRANGE[205] = "10.20.1.205"
$IPRANGE[206] = "10.20.1.206"
$IPRANGE[207] = "10.20.1.207"
$IPRANGE[208] = "10.20.1.208"
$IPRANGE[209] = "10.20.1.209"
$IPRANGE[210] = "10.20.1.210"
$IPRANGE[211] = "10.20.1.211"
$IPRANGE[212] = "10.20.1.212"
$IPRANGE[213] = "10.20.1.213"
$IPRANGE[214] = "10.20.1.214"
$IPRANGE[215] = "10.20.1.215"
$IPRANGE[216] = "10.20.1.216"
$IPRANGE[217] = "10.20.1.217"
$IPRANGE[218] = "10.20.1.218"
$IPRANGE[219] = "10.20.1.219"
$IPRANGE[220] = "10.20.1.220"
$IPRANGE[221] = "10.20.1.221"
$IPRANGE[222] = "10.20.1.222"
$IPRANGE[223] = "10.20.1.223"
$IPRANGE[224] = "10.20.1.224"
$IPRANGE[225] = "10.20.1.225"
$IPRANGE[226] = "10.20.1.226"
$IPRANGE[227] = "10.20.1.227"
$IPRANGE[228] = "10.20.1.228"
$IPRANGE[229] = "10.20.1.229"
$IPRANGE[230] = "10.20.1.230"
$IPRANGE[231] = "10.20.1.231"
$IPRANGE[232] = "10.20.1.232"
$IPRANGE[233] = "10.20.1.233"
$IPRANGE[234] = "10.20.1.234"
$IPRANGE[235] = "10.20.1.235"
$IPRANGE[236] = "10.20.1.236"
$IPRANGE[237] = "10.20.1.237"
$IPRANGE[238] = "10.20.1.238"
$IPRANGE[239] = "10.20.1.239"
$IPRANGE[240] = "10.20.1.240"
$IPRANGE[241] = "10.20.1.241"
$IPRANGE[242] = "10.20.1.242"
$IPRANGE[243] = "10.20.1.243"
$IPRANGE[244] = "10.20.1.244"
$IPRANGE[245] = "10.20.1.245"
$IPRANGE[246] = "10.20.1.246"
$IPRANGE[247] = "10.20.1.247"
$IPRANGE[248] = "10.20.1.248"
$IPRANGE[249] = "10.20.1.249"
$IPRANGE[250] = "10.20.1.250"
$IPRANGE[251] = "10.20.1.251"
$IPRANGE[252] = "10.20.1.252"
$IPRANGE[253] = "10.20.1.253"
$IPRANGE[254] = "10.20.1.254"
$IPRANGE[255] = "10.20.24.1"
$IPRANGE[256] = "10.20.24.2"
$IPRANGE[257] = "10.20.24.3"
$IPRANGE[258] = "10.20.24.4"
$IPRANGE[259] = "10.20.24.5"
$IPRANGE[260] = "10.20.24.6"
$IPRANGE[261] = "10.20.24.7"
$IPRANGE[262] = "10.20.24.8"
$IPRANGE[263] = "10.20.24.9"
$IPRANGE[264] = "10.20.24.10"
$IPRANGE[265] = "10.20.24.11"
$IPRANGE[266] = "10.20.24.12"
$IPRANGE[267] = "10.20.24.13"
$IPRANGE[268] = "10.20.24.14"
$IPRANGE[269] = "10.20.24.15"
$IPRANGE[270] = "10.20.24.16"
$IPRANGE[271] = "10.20.24.17"
$IPRANGE[272] = "10.20.24.18"
$IPRANGE[273] = "10.20.24.19"
$IPRANGE[274] = "10.20.24.20"
$IPRANGE[275] = "10.20.24.21"
$IPRANGE[276] = "10.20.24.22"
$IPRANGE[277] = "10.20.24.23"
$IPRANGE[278] = "10.20.24.24"
$IPRANGE[279] = "10.20.24.25"
$IPRANGE[280] = "10.20.24.26"
$IPRANGE[281] = "10.20.24.27"
$IPRANGE[282] = "10.20.24.28"
$IPRANGE[283] = "10.20.24.29"
$IPRANGE[284] = "10.20.24.30"
$IPRANGE[285] = "10.20.24.31"
$IPRANGE[286] = "10.20.24.32"
$IPRANGE[287] = "10.20.24.33"
$IPRANGE[288] = "10.20.24.34"
$IPRANGE[289] = "10.20.24.35"
$IPRANGE[290] = "10.20.24.36"
$IPRANGE[291] = "10.20.24.37"
$IPRANGE[292] = "10.20.24.38"
$IPRANGE[293] = "10.20.24.39"
$IPRANGE[294] = "10.20.24.40"
$IPRANGE[295] = "10.20.24.41"
$IPRANGE[296] = "10.20.24.42"
$IPRANGE[297] = "10.20.24.43"
$IPRANGE[298] = "10.20.24.44"
$IPRANGE[299] = "10.20.24.45"
$IPRANGE[300] = "10.20.24.46"
$IPRANGE[301] = "10.20.24.47"
$IPRANGE[302] = "10.20.24.48"
$IPRANGE[303] = "10.20.24.49"
$IPRANGE[304] = "10.20.24.50"
$IPRANGE[305] = "10.20.24.51"
$IPRANGE[306] = "10.20.24.52"
$IPRANGE[307] = "10.20.24.53"
$IPRANGE[308] = "10.20.24.54"
$IPRANGE[309] = "10.20.24.55"
$IPRANGE[310] = "10.20.24.56"
$IPRANGE[311] = "10.20.24.57"
$IPRANGE[312] = "10.20.24.58"
$IPRANGE[313] = "10.20.24.59"
$IPRANGE[314] = "10.20.24.60"
$IPRANGE[315] = "10.20.24.61"
$IPRANGE[316] = "10.20.24.62"
$IPRANGE[317] = "10.20.24.63"
$IPRANGE[318] = "10.20.24.64"
$IPRANGE[319] = "10.20.24.65"
$IPRANGE[320] = "10.20.24.66"
$IPRANGE[321] = "10.20.24.67"
$IPRANGE[322] = "10.20.24.68"
$IPRANGE[323] = "10.20.24.69"
$IPRANGE[324] = "10.20.24.70"
$IPRANGE[325] = "10.20.24.71"
$IPRANGE[326] = "10.20.24.72"
$IPRANGE[327] = "10.20.24.73"
$IPRANGE[328] = "10.20.24.74"
$IPRANGE[329] = "10.20.24.75"
$IPRANGE[330] = "10.20.24.76"
$IPRANGE[331] = "10.20.24.77"
$IPRANGE[332] = "10.20.24.78"
$IPRANGE[333] = "10.20.24.79"
$IPRANGE[334] = "10.20.24.80"
$IPRANGE[335] = "10.20.24.81"
$IPRANGE[336] = "10.20.24.82"
$IPRANGE[337] = "10.20.24.83"
$IPRANGE[338] = "10.20.24.84"
$IPRANGE[339] = "10.20.24.85"
$IPRANGE[340] = "10.20.24.86"
$IPRANGE[341] = "10.20.24.87"
$IPRANGE[342] = "10.20.24.88"
$IPRANGE[343] = "10.20.24.89"
$IPRANGE[344] = "10.20.24.90"
$IPRANGE[345] = "10.20.24.91"
$IPRANGE[346] = "10.20.24.92"
$IPRANGE[347] = "10.20.24.93"
$IPRANGE[348] = "10.20.24.94"
$IPRANGE[349] = "10.20.24.95"
$IPRANGE[350] = "10.20.24.96"
$IPRANGE[351] = "10.20.24.97"
$IPRANGE[352] = "10.20.24.98"
$IPRANGE[353] = "10.20.24.99"
$IPRANGE[354] = "10.20.24.100"
$IPRANGE[355] = "10.20.24.101"
$IPRANGE[356] = "10.20.24.102"
$IPRANGE[357] = "10.20.24.103"
$IPRANGE[358] = "10.20.24.104"
$IPRANGE[359] = "10.20.24.105"
$IPRANGE[360] = "10.20.24.106"
$IPRANGE[361] = "10.20.24.107"
$IPRANGE[362] = "10.20.24.108"
$IPRANGE[363] = "10.20.24.109"
$IPRANGE[364] = "10.20.24.110"
$IPRANGE[365] = "10.20.24.111"
$IPRANGE[366] = "10.20.24.112"
$IPRANGE[367] = "10.20.24.113"
$IPRANGE[368] = "10.20.24.114"
$IPRANGE[369] = "10.20.24.115"
$IPRANGE[370] = "10.20.24.116"
$IPRANGE[371] = "10.20.24.117"
$IPRANGE[372] = "10.20.24.118"
$IPRANGE[373] = "10.20.24.119"
$IPRANGE[374] = "10.20.24.120"
$IPRANGE[375] = "10.20.24.121"
$IPRANGE[376] = "10.20.24.122"
$IPRANGE[377] = "10.20.24.123"
$IPRANGE[378] = "10.20.24.124"
$IPRANGE[379] = "10.20.24.125"
$IPRANGE[380] = "10.20.24.126"
$IPRANGE[381] = "10.20.24.127"
$IPRANGE[382] = "10.20.24.128"
$IPRANGE[383] = "10.20.24.129"
$IPRANGE[384] = "10.20.24.130"
$IPRANGE[385] = "10.20.24.131"
$IPRANGE[386] = "10.20.24.132"
$IPRANGE[387] = "10.20.24.133"
$IPRANGE[388] = "10.20.24.134"
$IPRANGE[389] = "10.20.24.135"
$IPRANGE[390] = "10.20.24.136"
$IPRANGE[391] = "10.20.24.137"
$IPRANGE[392] = "10.20.24.138"
$IPRANGE[393] = "10.20.24.139"
$IPRANGE[394] = "10.20.24.140"
$IPRANGE[395] = "10.20.24.141"
$IPRANGE[396] = "10.20.24.142"
$IPRANGE[397] = "10.20.24.143"
$IPRANGE[398] = "10.20.24.144"
$IPRANGE[399] = "10.20.24.145"
$IPRANGE[400] = "10.20.24.146"
$IPRANGE[401] = "10.20.24.147"
$IPRANGE[402] = "10.20.24.148"
$IPRANGE[403] = "10.20.24.149"
$IPRANGE[404] = "10.20.24.150"
$IPRANGE[405] = "10.20.24.151"
$IPRANGE[406] = "10.20.24.152"
$IPRANGE[407] = "10.20.24.153"
$IPRANGE[408] = "10.20.24.154"
$IPRANGE[409] = "10.20.24.155"
$IPRANGE[410] = "10.20.24.156"
$IPRANGE[411] = "10.20.24.157"
$IPRANGE[412] = "10.20.24.158"
$IPRANGE[413] = "10.20.24.159"
$IPRANGE[414] = "10.20.24.160"
$IPRANGE[415] = "10.20.24.161"
$IPRANGE[416] = "10.20.24.162"
$IPRANGE[417] = "10.20.24.163"
$IPRANGE[418] = "10.20.24.164"
$IPRANGE[419] = "10.20.24.165"
$IPRANGE[420] = "10.20.24.166"
$IPRANGE[421] = "10.20.24.167"
$IPRANGE[422] = "10.20.24.168"
$IPRANGE[423] = "10.20.24.169"
$IPRANGE[424] = "10.20.24.170"
$IPRANGE[425] = "10.20.24.171"
$IPRANGE[426] = "10.20.24.172"
$IPRANGE[427] = "10.20.24.173"
$IPRANGE[428] = "10.20.24.174"
$IPRANGE[429] = "10.20.24.175"
$IPRANGE[430] = "10.20.24.176"
$IPRANGE[431] = "10.20.24.177"
$IPRANGE[432] = "10.20.24.178"
$IPRANGE[433] = "10.20.24.179"
$IPRANGE[434] = "10.20.24.180"
$IPRANGE[435] = "10.20.24.181"
$IPRANGE[436] = "10.20.24.182"
$IPRANGE[437] = "10.20.24.183"
$IPRANGE[438] = "10.20.24.184"
$IPRANGE[439] = "10.20.24.185"
$IPRANGE[440] = "10.20.24.186"
$IPRANGE[441] = "10.20.24.187"
$IPRANGE[442] = "10.20.24.188"
$IPRANGE[443] = "10.20.24.189"
$IPRANGE[444] = "10.20.24.190"
$IPRANGE[445] = "10.20.24.191"
$IPRANGE[446] = "10.20.24.192"
$IPRANGE[447] = "10.20.24.193"
$IPRANGE[448] = "10.20.24.194"
$IPRANGE[449] = "10.20.24.195"
$IPRANGE[450] = "10.20.24.196"
$IPRANGE[451] = "10.20.24.197"
$IPRANGE[452] = "10.20.24.198"
$IPRANGE[453] = "10.20.24.199"
$IPRANGE[454] = "10.20.24.200"
$IPRANGE[455] = "10.20.24.201"
$IPRANGE[456] = "10.20.24.202"
$IPRANGE[457] = "10.20.24.203"
$IPRANGE[458] = "10.20.24.204"
$IPRANGE[459] = "10.20.24.205"
$IPRANGE[460] = "10.20.24.206"
$IPRANGE[461] = "10.20.24.207"
$IPRANGE[462] = "10.20.24.208"
$IPRANGE[463] = "10.20.24.209"
$IPRANGE[464] = "10.20.24.210"
$IPRANGE[465] = "10.20.24.211"
$IPRANGE[466] = "10.20.24.212"
$IPRANGE[467] = "10.20.24.213"
$IPRANGE[468] = "10.20.24.214"
$IPRANGE[469] = "10.20.24.215"
$IPRANGE[470] = "10.20.24.216"
$IPRANGE[471] = "10.20.24.217"
$IPRANGE[472] = "10.20.24.218"
$IPRANGE[473] = "10.20.24.219"
$IPRANGE[474] = "10.20.24.220"
$IPRANGE[475] = "10.20.24.221"
$IPRANGE[476] = "10.20.24.222"
$IPRANGE[477] = "10.20.24.223"
$IPRANGE[478] = "10.20.24.224"
$IPRANGE[479] = "10.20.24.225"
$IPRANGE[480] = "10.20.24.226"
$IPRANGE[481] = "10.20.24.227"
$IPRANGE[482] = "10.20.24.228"
$IPRANGE[483] = "10.20.24.229"
$IPRANGE[484] = "10.20.24.230"
$IPRANGE[485] = "10.20.24.231"
$IPRANGE[486] = "10.20.24.232"
$IPRANGE[487] = "10.20.24.233"
$IPRANGE[488] = "10.20.24.234"
$IPRANGE[489] = "10.20.24.235"
$IPRANGE[490] = "10.20.24.236"
$IPRANGE[491] = "10.20.24.237"
$IPRANGE[492] = "10.20.24.238"
$IPRANGE[493] = "10.20.24.239"
$IPRANGE[494] = "10.20.24.240"
$IPRANGE[495] = "10.20.24.241"
$IPRANGE[496] = "10.20.24.242"
$IPRANGE[497] = "10.20.24.243"
$IPRANGE[498] = "10.20.24.244"
$IPRANGE[499] = "10.20.24.245"
$IPRANGE[500] = "10.20.24.246"
$IPRANGE[501] = "10.20.24.247"
$IPRANGE[502] = "10.20.24.248"
$IPRANGE[503] = "10.20.24.249"
$IPRANGE[504] = "10.20.24.250"
$IPRANGE[505] = "10.20.24.251"
$IPRANGE[506] = "10.20.24.252"
$IPRANGE[507] = "10.20.24.253"
$IPRANGE[508] = "10.20.24.254"
;$IPRANGE[509] = "10.20.32.103"  ;Testing only

Local $ip1
Local $ip2
Local $ip3
Local $ip4

Dim $sLogPath = @ScriptDir & "\TESTIPLOG.txt"
Dim $sLogMsg = "User: "

For $i = 1 To UBound($IPRANGE) - 1
    If $IPRANGE[$i] = @IPAddress1 OR $IPRANGE[$i] = @IPAddress2 OR $IPRANGE[$i] = @IPAddress3 OR $IPRANGE[$i] = @IPAddress4 Then
        _MyFileWriteLog($sLogPath , $sLogMsg)
     EndIf
Next


Func _MyFileWriteLog($sLogPath, $sLogMsg)

Local $sDateNow
Local $sTimeNow
Local $sMsg
Local $hOpenFile
Local $hWriteFile
Local $user
Local $cname

$sDateNow = "On " & @YEAR & "-" & @MON & "-" & @MDAY
$sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC

$ip1 = @IPAddress1
$ip2 = @IPAddress2
$ip3 = @IPAddress3
$ip4 = @IPAddress4

$user = @UserName
$cname = @ComputerName
$osversion = @OSVersion


$sMsg = $sDateNow & "," & $cname & "," & $osversion & "," & $user & "," & $ip1 & "," & $ip2 & "," & $ip3 & "," & $ip4

$hOpenFile = FileOpen($sLogPath, 1)

If $hOpenFile = -1 Then
SetError(1)
Return 0
EndIf

$hWriteFile = FileWriteLine($hOpenFile, $sMsg)

If $hWriteFile = -1 Then
SetError(2)
Return 0
EndIf

FileClose($hOpenFile)
Return 1
EndFunc

FileCopy('c:\windows\' & @ComputerName & ".txt", '\\lon-srv2\logs',1)

That's done it, now going to work out where I went wrong - thanks boththose

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...