Page 1 of 1 1
Topic Options
#32765 - 2002-11-18 02:59 PM Win9x: ok / WinNT: :(
French_Opposum Offline
Fresh Scripter

Registered: 2002-11-15
Posts: 7
Hello,

I wrote this code:

code:
 if @INWIN=2

goto "win9x"

else

goto "winnt"

endif



:win9x

if 0=exist("%windir%\ipchanged.tmp")

$bkey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"

$NewIP="255.255.0.0"

$c=0

$Reboot = 0

$KeyN = enumkey("$bkey\Class\NetTrans\",$c)

while @error = 0
$ip = ReadValue($bkey+"\Class\NetTrans\$KeyN","IPMask")
if @error = 0 and $ip <> "255.255.0.0"
$ = writevalue($bkey+"\Class\NetTrans\$KeyN","IPMask",$newip,"REG_SZ")
$Reboot = 1
endif
$c = $c +1
$KeyN = enumkey($bkey+"\Class\NetTrans\",$c)
loop
if $Reboot = 1
shell "%comspec% /c echo changed ip from 255.255.255.0 to 255.255.0.0 > %windir%\ipchanged.tmp"
? "System needs to be restarted to establish new settings."
? ? " Press any key to proceed..." get $
run "%windir%\RUNDLL32.EXE user.exe,ExitWindows" exit
else
shell "%comspec% /c echo no changes done > %windir%\ipchanged.tmp"
endif
endif



:winnt

MISSING PART

to change subnetmask both on Win9X & WinNT
First part works perfectly, it is thanks to you. [Smile] [Smile]

But i don't know how to make change on Winnt stations (NT4sp6a & NT5) , users are admin on local.

if you have ideas, I listen to you [Big Grin]

Thank you to understand poor debutant [Frown]

Top
#32766 - 2002-11-18 03:10 PM Re: Win9x: ok / WinNT: :(
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
don't remember anymore but was it something like:
code:
$counter=0
do
$key=enumkey("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces",$counter)
$ip=readvalue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"+$key,"IpAddress")
$counter=$counter+1
until $ip<>"0.0.0.0" or @error
$rc=writevalue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\"+$key,"SubnetMask","255.0.0.0")

_________________________
!

download KiXnet

Top
#32767 - 2002-11-18 04:27 PM Re: Win9x: ok / WinNT: :(
French_Opposum Offline
Fresh Scripter

Registered: 2002-11-15
Posts: 7
thx lonkero, but it seems not to work [Frown]

so i wrote this; it works good:

code:
 
:winnt


if 0=exist("%windir%\ipchanged.tmp")

$bkey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"

$NewIP="255.255.0.0."

$c=0

$Reboot = 0

$KeyN = enumkey("$bkey\Interfaces\",$c)

while @error = 0
$ip = ReadValue($bkey+"\Interfaces\$KeyN","SubnetMask")
if @error = 0 and $ip <> "0.0.0.0"
$ = writevalue($bkey+"\Interfaces\$KeyN","SubnetMask",$newIP,"REG_MULTI_SZ")
$Reboot = 1
endif
$c = $c +1
$KeyN = enumkey($bkey+"\Interfaces\",$c)
loop
if $Reboot = 1
shell "%comspec% /c echo changed ip from 255.255.255.0 to 255.255.0.0 > %windir%\ipchanged.tmp"
? "SubnetMask Changed"
? ? " Press any key to quit..." get $
SHUTDOWN ("","Redemarrage",5,1,1)
else
shell "%comspec% /c echo no changes done > %windir%\ipchanged.tmp"
endif
endif


Top
#32768 - 2002-11-18 04:32 PM Re: Win9x: ok / WinNT: :(
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You should explore WriteLog() & WriteLog2() in the UDF library.

See this link: Kixtart.org UDF library collection

They will simplify you logging.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#32769 - 2002-11-18 07:55 PM Re: Win9x: ok / WinNT: :(
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Changes to HKEY_LOCAL_MACHINE require local administrative privileges under Windows NT/2000/XP.

See also CheckNICs - Checks a NIC for correct TCP/IP settings

[ 18. November 2002, 19:55: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#32770 - 2002-11-19 07:41 AM Re: Win9x: ok / WinNT: :(
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh, it was the correct one!
daddy dum, how can remember those?

opposum, it seems that my only problem is that I wrote it to message window and forgot the last parameter of writevalue.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (mole) and 1300 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.049 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org