I am trying to change the Registry in Vista, but it is protected so I want my kix script to generate a reg file and use the elevate.cmd to import it.

Here is what the reg file (printerins.reg) should contain:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\xxx.xxx.xxx.xxx]
"Protocol"=dword:00000002
"Version"=dword:00000002
"Hostname"="xxx.xxx.xxx.xxx"
"IPAddress"=""
"HWAddress"=""
"PortNumber"=dword:00000203
"SNMP Community"="public"
"SNMP Enabled"=dword:00000001
"SNMP Index"=dword:00000001
"PortMonMibPortIndex"=dword:00000000
"Queue"="RAW"
"Double Spool"=dword:00000001

Here is the code:

 Code:
IF $VISTA32="YES" OR $VISTA64="YES"
	$IPPRINTERKEY='$REMOTEPC\$HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\PRINT\MONITORS\STANDARD TCP/IP PORT\PORTS\' +$PORT	
			ELSE
				$IPPRINTERKEY='$REMOTEPC\$HKLM\SYSTEM\CURRENTCONTROLSET\CONTROL\PRINT\MONITORS\STANDARD TCP/IP PORT\PORTS\IP_' +$PORT
			ENDIF

			? "IPPRINTERKEY: " $IPPRINTERKEY

			IF KEYEXIST($IPPRINTERKEY)
				$=DELTREE($IPPRINTERKEY)
			ENDIF
			
			IF $VISTA32="YES" OR $VISTA64="YES"
				IF NOT KEYEXIST($IPPRINTERKEY)
			        	$=ADDKEY($IPPRINTERKEY)
				        $=WRITEVALUE($IPPRINTERKEY,"Double Spool","00000001","REG_DWORD")
					$=WRITEVALUE($IPPRINTERKEY,"HostName","$PORT", "REG_SZ")
					$=WRITEVALUE($IPPRINTERKEY,"HWAddress","","REG_SZ")
					$=WRITEVALUE($IPPRINTERKEY,"IPAddress","","REG_SZ")
					$=WRITEVALUE($IPPRINTERKEY,"SNMP Community","public","REG_SZ")
        				$=WRITEVALUE($IPPRINTERKEY,"SNMP Index","00000001","REG_DWORD")
			        	$=WRITEVALUE($IPPRINTERKEY,"VERSION","00000002","REG_DWORD")
				ENDIF
			ELSE
				IF NOT KEYEXIST($IPPRINTERKEY)
			        	$=ADDKEY($IPPRINTERKEY)
				        $=WRITEVALUE($IPPRINTERKEY,"Double Spool","00000001","REG_DWORD")
					$=WRITEVALUE($IPPRINTERKEY,"HostName","", "REG_SZ")
					$=WRITEVALUE($IPPRINTERKEY,"HWAddress","","REG_SZ")
					$=WRITEVALUE($IPPRINTERKEY,"IPAddress","$PORT","REG_SZ")
					$=WRITEVALUE($IPPRINTERKEY,"SNMP Community","public","REG_SZ")
        				$=WRITEVALUE($IPPRINTERKEY,"SNMP Index","00000001","REG_DWORD")
			     		$=WRITEVALUE($IPPRINTERKEY,"VERSION","00000001","REG_DWORD")
				ENDIF
			ENDIF


FOR EACH $SPOOLER IN $SERVICES
				IF $VISTA32="YES" OR $VISTA64="YES"
					SHELL '%COMSPEC% /C C:\NETWORK\ELEVATE.CMD NET START "Print Spooler" >NUL'
				ELSE
					$=EXECUTE('$$=$$SPOOLER.STARTSERVICE()')
				ENDIF
			NEXT
$OBJECTS=GETOBJECT("WINMGMTS:{IMPERSONATIONLEVEL=IMPERSONATE}!"+$REMOTEPC+"\ROOT\CIMV2")

			IF NOT @ERROR=0
				EXIT -4
			ENDIF

			$SERVICES=$OBJECTS.EXECQUERY('Select * from Win32_Service WHERE Name = "Spooler"')
      			
			FOR EACH $SPOOLER IN $SERVICES
				IF $VISTA32="YES" OR $VISTA64="YES"
					SHELL '%COMSPEC% /C C:\NETWORK\ELEVATE.CMD NET STOP "Print Spooler" >NUL'
				ELSE
					$=EXECUTE('$$=$$SPOOLER.STOPSERVICE()')
				ENDIF
			NEXT
	 		
			IF $VISTA32="YES" OR $VISTA64="YES"
				? "Give User Time To Answer Prompts..."
				SLEEP 15
			ELSE
				SLEEP 3
			ENDIF
			IF $VISTA32="YES" OR $VISTA64="YES"
				? "Give User Time To Answer Prompts..."
				SLEEP 15
			ELSE
				SLEEP 3
			ENDIF

			IF $VISTA32="YES" OR $VISTA64="YES"
				$PORT='$PORT'	
			ELSE
				$PORT='IP_$PORT'
			ENDIF


I did some brief searching on the forums but couldn't find anything that provided what I was looking for. I am sure I could piece meal something together but hoped there were something already out there...


Edited by KIXKicks (2007-08-13 02:50 PM)