#49623 - 2000-04-25 08:41 AM
Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
Has anybody done a runonce Static IP address to DHCP ??Just on NT 4 Workstation. Regards Colin
|
|
Top
|
|
|
|
#49626 - 2000-05-03 12:38 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
I did save the code... here it is..; Static IP to DHCP Conversion Custom Script [Begin] if ingroup('DHCP-Conversion') and $ConnType='LAN' $HKLM='HKEY_LOCAL_MACHINE' $SCCSS='SYSTEM\CurrentControlSet\Services' $Key='$HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\' if $OStype='NT' $Key=$Key+'Active' endif $Key=$Key+'ComputerName' $ComputerName=readvalue('$Key','ComputerName') $Index=0 if $OStype<>'NT' ; Win95/98 Routine hcpLoop9x $Key=enumkey('$HKLM\$SCCSS\Class\NetTrans\',$Index) $Err=@ERROR $DHCPEnabled=readvalue('$HKLM\$SCCSS\Class\NetTrans\$Key','IPAddress') $Index=$Index+1 if $Err=0 if $DHCPEnabled<>'0.0.0.0' ; * Change from Static to DHCP * $result=writevalue('$HKLM\$SCCSS\Class\NetTrans\$Key','IPAddress','0.0.0.0','REG_SZ') $result=writevalue('$HKLM\$SCCSS\Class\NetTrans\$Key','IPMask','0.0.0.0','REG_SZ') $result=delvalue('$HKLM\$SCCSS\Class\NetTrans\$Key','DefaultGateway') ; * Clear WINS, DNS, and Enable Use WINS for Windows DNS Resolution * $result=writevalue('$HKLM\$SCCSS\VxD\MSTCP','EnableDNS','0','REG_SZ') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','NameServer') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','NameServer1') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','NameServer2') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','SearchList') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','Domain') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','NodeType') $result=delvalue('$HKLM\$SCCSS\VxD\MSTCP','ScopeID') $RestartFlag=2 ; 2=force reboot endif goto DhcpLoop9x endif ; key enumeration complete else ; NT Routine if $NTtype<>'Server' hcpLoopNT $Key=enumkey('$HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\',$Index) $Err=@ERROR $NicYN=0 $NicYN=readvalue('$HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\$Key','Hidden') if $NicYN=1 $Index=$Index+1 $NicYN=0 goto DhcpLoopNT endif $NicType=readvalue('$HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\$Key','ServiceName') $DHCPEnabled=readvalue('$HKLM\$SCCSS\$NicType\Parameters\TCPIP','EnableDHCP') $Index=$Index+1 if $Err=0 if $DHCPEnabled<>'1' ; * Change from Static to DHCP * $result=writevalue('$HKLM\$SCCSS\$NicType\Parameters\TCPIP','EnableDHCP','1','REG_DWORD') $result=writevalue('$HKLM\$SCCSS\$NicType\Parameters\TCPIP','IPAddress','0.0.0.0','REG_MULTI_SZ') $result=writevalue('$HKLM\$SCCSS\$NicType\Parameters\TCPIP','SubnetMask','0.0.0.0','REG_MULTI_SZ') $result=writevalue('$HKLM\$SCCSS\$NicType\Parameters\TCPIP','DefaultGateway','','REG_MULTI_SZ') $result=writevalue('$HKLM\$SCCSS\DHCP','Start','2','REG_DWORD') ; * Clear WINS, DNS, and Enable Use WINS for Windows DNS Resolution * $result=writevalue('$HKLM\$SCCSS\NetBT\Adapters\$NicType','NameServer','','REG_SZ') $result=writevalue('$HKLM\$SCCSS\NetBT\Adapters\$NicType','NameServerBackup','','REG_SZ') $result=writevalue('$HKLM\$SCCSS\NetBT\Parameters','EnableDNS','1','REG_DWORD') $result=writevalue('$HKLM\$SCCSS\TCPIP\Parameters','NameServer','','REG_SZ') $result=writevalue('$HKLM\$SCCSS\TCPIP\Parameters','SearchList','','REG_SZ') $result=writevalue('$HKLM\$SCCSS\TCPIP\Parameters','Domain','','REG_SZ') $RestartFlag=2 ; 2=force reboot endif goto DhcpLoopNT endif endif ; key enumeration complete endif ; not NT Server if $RestartFlag>0 $result=messagebox('Your TCP/IP system settings have been converted to DHCP. Your system must be restarted for these changes to take effect.','ScriptLogic Notice',4112,60) endif endif ; ingroup ; Static IP to DHCP Conversion Custom Script [End]
|
|
Top
|
|
|
|
#49627 - 2000-05-03 01:45 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
Thanks for the script...
|
|
Top
|
|
|
|
#49629 - 2000-05-04 07:20 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
The script is working great, with a nice shutdown and reboot....When I login as a test user, that has NO Admin rights, NO changes are made (It reboots evertime...which is nice) How do you allow non-Admins to run the script that change the registry settings ?? Or...How did you get around it ??? Ta Very much Colin
|
|
Top
|
|
|
|
#49631 - 2000-05-08 07:51 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
Thanks...I've played around with it and I've decided I'm really stupid as I cannot seem to get it to do anything..(Anything useful that is !!) example su <username> <domain> < <location of password text file> -n I've tried lots (and lots) of variations. Questions... 1. Do you run it in the if..endif that does the change of the registry settings? 2. Or can it sit outside? 3. Am I totally stupid?? 4. Shall I become a road sweeper ?? All answers on a back of a postcard please !!!
|
|
Top
|
|
|
|
#49632 - 2000-05-08 09:09 AM
Re: Static to DHCP
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
echo <password>|su <user> <command>Very important that there is no space between <password> and the | (pipe) command. in order for you to make the change with kix as a logon script, you will have to run the logon script with the su command. or you can just shell out of the main logon script and run another kix script (with your reg changes) with the su command..... shell "%comspec% /c echo <password>|su <user> %0\..\kix32 %0\..\regfix.kix" or something like that  Bryce
[This message has been edited by Bryce (edited 08 May 2000).]
|
|
Top
|
|
|
|
#49634 - 2000-05-09 04:41 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
Thanks Bryce & Jochentried the %compspec% line. Now I get a RPC 1722 error unable to find RPC server Set Kix scipt to install suss.exe. Use the Domain admin account & password. Also tried local admin account. My account. The Pope's account (He was upset about that, had to do some Hail Mary's). Any more advice ???
|
|
Top
|
|
|
|
#49637 - 2000-05-10 02:34 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
Hi BryceI've tried the updated %comspec% line. A failure occurs at this point (DOS screen appears, the word FAILURE and some other words that I don't get the chance to read before the DOS screen closes) The Kix32 file is located in the Winnt\System32 directory on all the PC's. DHCPreg.kix is located on the DC's Netlogon share. As for the suss.exe, this is copied over from the Netlogon share to the System32 directory. Then the script runs a shell to do the suss.exe -install. The problem seems to be; 1. The suss needs to be installed by an administrator. 2. The registry changes need to be done by an administrator. So Suss can't be run from the login script as it won't be installed by a domain user account on the PC. Su can't be run until suss has been installed. Nice catch 22 situation....
|
|
Top
|
|
|
|
#49639 - 2000-11-29 08:16 AM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
Just in case anyone else spends several hours trying to get this to work like I did here's a hint: if you are using bat2exec to convert your .bat to a .com then you MUST have a space after the pipe (|). By the way has anyone managed to get a batch file with SET commands to convert to .com using bat2exec ?------------------
|
|
Top
|
|
|
|
#49640 - 2000-11-29 05:04 PM
Re: Static to DHCP
|
Roger
Fresh Scripter
Registered: 2000-11-27
Posts: 26
Loc: Urbandale, IA USA
|
Hi Chris,Where do you get bat2exe? Sounds like a useful tool.
|
|
Top
|
|
|
|
#49641 - 2000-11-29 05:11 PM
Re: Static to DHCP
|
Anonymous
Anonymous
Unregistered
|
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 823 anonymous users online.
|
|
|