Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Generic Printer Configuration

Keywords: 	 Generic Printer Configuration


Handle_Name=RegOpenKey(@REGMACHINE,"system\currentcontrolset\control\computername\computername")
S1=regqueryvalue(Handle_name,"[computername]")
regclosekey(Handle_Name)
x=0
While RegExistKey(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\000%x%")
Handle=RegOpenKey(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\000%x%")
ErrorMode(@Off)
S2=RegQueryValue(Handle,"[IPAddress]")
S3=RegQueryValue(Handle,"[IPMask]")
S4=RegQueryValue(Handle,"[DefaultGateway]")
if LastError() !=1233 then break
ErrorMode(@Cancel)
RegCloseKey(handle)
x=x+1
EndWhile

if isdefined(s2)==0 || isdefined(s3)==0|| isdefined(s3)==0 then exit



;Break IPs down to octets for display
:AGAIN
x=0
while x < 5
	x=x+1
	if x == 1 then a = 2 
	if x == 2 then a = 3
	if x == 3 then a = 4
	spaces=StrReplace(s%a%,"."," ")
	ParseData (spaces)
	param1_%a%=param1
	param2_%a%=param2
	param3_%a%=param3
	param4_%a%=param4
endwhile

Current_printer=IniRead("Windows", "device","(No default printer chosen)")
comma=StrIndex (current_printer, ",", 1, @FWDSCAN)
s10=StrSub (Current_printer, 1, comma-1)
s10=strupper(s10)
handle=regopenkey(@REGMACHINE,"system\currentcontrolset\control\Print\Printers")
printers=""
list=""
For x=1 to 50
printer=RegQueryKey(handle, x)
	If printer=="Rendering Subsystem" then next
printers=strcat(printers,printer)
  If printer=="" then break
  list=strcat(printers,@TAB)
printers=list
next 
regclosekey(handle)

IntControl(33, 0, 0, 0, 0) ; Disables multiple selections in printer box

SettingsFormat=`WWWDLGED,5.0`

SettingsCaption=`Change settings`
SettingsX=152
SettingsY=60
SettingsWidth=120
SettingsHeight=75
SettingsNumControls=20
Settings01=`30,5,75,DEFAULT,STATICTEXT,DEFAULT,"CURRENT SETTINGS"`
Settings02=`1,15,38,DEFAULT,STATICTEXT,DEFAULT,"Computer name"`
Settings03=`40,12,60,DEFAULT,EDITBOX,Name,%S1%`
Settings04=`12,26,28,DEFAULT,STATICTEXT,DEFAULT,"IP Address"`
Settings05=`40,23,15,DEFAULT,EDITBOX,IP1,%param1_2%`
Settings06=`55,23,15,DEFAULT,EDITBOX,IP2,%param2_2%`
Settings07=`70,23,15,DEFAULT,EDITBOX,IP3,%param3_2%`
Settings08=`85,23,15,DEFAULT,EDITBOX,IP4,%param4_2%`
Settings09=`16,37,23,DEFAULT,STATICTEXT,DEFAULT,"Gateway"`
Settings10=`40,34,15,DEFAULT,EDITBOX,gateway1,%param1_4%`
Settings11=`55,34,15,DEFAULT,EDITBOX,gateway2,%param2_4%`
Settings12=`70,34,15,DEFAULT,EDITBOX,gateway3,%param3_4%`
Settings13=`85,34,15,DEFAULT,EDITBOX,gateway4,%param4_4%`
Settings14=`24,48,16,DEFAULT,STATICTEXT,DEFAULT,"Mask"`
Settings15=`40,45,15,DEFAULT,EDITBOX,mask1,%param1_3%`
Settings16=`55,45,15,DEFAULT,EDITBOX,mask2,%param2_3%`
Settings17=`70,45,15,DEFAULT,EDITBOX,mask3,%param3_3%`
Settings18=`85,45,15,DEFAULT,EDITBOX,mask4,%param4_3%`
Settings19=`5,60,51,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel",0`
Settings20=`64,60,51,DEFAULT,PUSHBUTTON,DEFAULT,"NEXT-->",1`

ButtonPushed=Dialog("Settings")
if ButtonPushed==1
IP=StrCat(IP1,".",IP2,".",IP3,".",IP4)
mask=StrCat(Mask1,".",Mask2,".",Mask3,".",Mask4)
gateway=StrCat(Gateway1,".",Gateway2,".",Gateway3,".",Gateway4)


;Display the new settings for confirmation


ChangesFormat=`WWWDLGED,5.0`

ChangesCaption=`NEW settings`
ChangesX=152
ChangesY=60
ChangesWidth=110
ChangesHeight=90
ChangesNumControls=12

Changes01=`30,3,75,DEFAULT,STATICTEXT,DEFAULT,"NEW SETTINGS"`
Changes02=`11,11,38,DEFAULT,STATICTEXT,DEFAULT,"Computer name"`
Changes03=`50,11,51,DEFAULT,STATICTEXT,DEFAULT,"........%name%"`
Changes04=`22,19,28,DEFAULT,STATICTEXT,DEFAULT,"IP Address"`
Changes05=`50,19,51,DEFAULT,STATICTEXT,DEFAULT,"........%IP%"`
Changes06=`26,27,23,DEFAULT,STATICTEXT,DEFAULT,"Gateway"`
Changes07=`50,27,51,DEFAULT,STATICTEXT,DEFAULT,"........%gateway%"`
Changes08=`34,35,16,DEFAULT,STATICTEXT,DEFAULT,"Mask"`
Changes09=`50,35,51,DEFAULT,STATICTEXT,DEFAULT,"........%Mask%"`
Changes10=`10,43,90,DEFAULT,PUSHBUTTON,DEFAULT,"Accept changes",1`
Changes11=`10,56,90,DEFAULT,PUSHBUTTON,DEFAULT,"Make more changes",2`
Changes12=`10,69,90,DEFAULT,PUSHBUTTON,DEFAULT,"Cancel changes",0`
ButtonPushed=Dialog("Changes")

if ButtonPushed==0 then break
if ButtonPushed==2
s2=IP
s3=mask
s4=gateway
goto AGAIN
endif

; Here's where the Registry gets updated and Windows is restarted
If ButtonPushed==1
s2=IP
s3=mask
s4=gateway

:REG_UPDATE
	Handle_Name=RegOpenKey(@REGMACHINE,"system\currentcontrolset\control\computername\computername")
	RegSetValue(Handle_name,"[computername]",name)
	RegCloseKey(Handle_Name)
	Handle=RegOpenKey(@REGMACHINE,"System\CurrentControlSet\Services\Class\NetTrans\0002")
	RegSetValue(Handle,"[IPAddress]",IP)
	RegSetValue(Handle,"[IPMask]",mask)
	RegSetValue(Handle,"[DefaultGateway]",gateway)
	regclosekey(Handle)



Article ID:   W14491
Filename:   Generic Printer Configuration.txt