:Start of NetworkConfig NetworkConfig.dsc
DragonSphereSoftware

Welcome to DragonSphere Software


If you are viewing this script in your browser you can save it as a VDS 5.x source file (*.dsc) to run it.




  #
  # DragonSphere Software's Home Page
  #  
  # All Source Files for this demo
  #
  # Requirements and Default info about NetConfig.dsc
  # You must have WMI (Windows Management Instramentation) installed and running
  # on the local and remote computer.
  # Goto the following URL for more information about enabling WMI on your Networked computers.
  # Microsoft WMI SDK
  # Internally NetConfig.dsu uses List create,3
  # So you will not be able to use that VDS list
  # 
# Below is a list of VDS variables that you can use for your # scripts. Do not change these variables. # %%LocalUserName = The user that is currently logged into the local computer. # %%LocalComputerName = The name of the computer you started this script on. # %%LocalDomainName = The Domain or workgroup that the %%LocalComputerName is located in. # All other variables are defined in this script and not in the NetConfig.dsu
# WARNING: The following buttons are not complete please read the code before using # SetIP, Rename, Title Network Config If @Greater(@Name(@SYSINFO(DSVER)),4) # GadgetX Commands used #DEFINE COMMAND,GADGETX,OLE,SET,DEFINE,CALL # GadgetX Functions used #DEFINE FUNCTION,GADGETX,OLE,GET,CALL,GETLASTERROR # Public NetConfig Commands used #DEFINE COMMAND,InitNetConfig,UnInitNetConfig,CleanUp # Public NetConfig Functions used #DEFINE FUNCTION,WMILogin,GetOSInfo,GetComputerList,GetRootNetList,ShutDownComputer,ReNameComputer,SetDHCP,EnableWINS,EnableDNS,SetIP,IPConfig,GetLocalUserName,GetLocalComputerName,GetLocalDomainName # Private NetConfig Functions #DEFINE FUNCTION,ARRAYTOVDS,VDSTOARRAY Else Warn This script will only run under VDS 5+ Exit End #INCLUDE NetConfig.dsc # Initialize Gadget, OLE, internal variables, and external constants. InitNetConfig # The front end uses these VDS list's below so you can still use them List Create,8 List create,9 :Main #Build a login dialog DIALOG CREATE,Please Login With WMI,244,403,425,347 # *** Modified by Dialog Designer on 9/30/2004 - 12:40 *** DIALOG ADD,TEXT,UserName_txt,52,50,,,User Name:,Enter your Administrator's User Name DIALOG ADD,EDIT,UserName_edt,49,109,287,19,%%LocalUserName,Enter your Administrator's User Name DIALOG ADD,TEXT,Password_txt,72,55,,,Password:,Enter your Administrator's Password DIALOG ADD,EDIT,Password_edt,70,110,286,19,,Enter your Administrator's Password,PASSWORD DIALOG ADD,TEXT,TEXT1,20,38,,,Please enter the information for the computer you would like WMI to access. DIALOG ADD,COMBO,Domain_cbo,96,112,284,21,,Select the Domain/Workgroup you want to login to...,CLICK DIALOG ADD,TEXT,Domain_txt,100,12,,,Domain/Workgroup:,Select the Domain/Workgroup you want to login to... DIALOG ADD,COMBO,Computer_cbo,128,112,284,21,,Select the Computer you want to login to...,CLICK DIALOG ADD,TEXT,Computer_txt,132,28,,,Computer Name:,Select the Computer you want to login to... DIALOG ADD,BUTTON,Login_btn,168,96,64,24,Login,Click to login with WMI DIALOG ADD,BUTTON,Cancel_btn,168,264,64,24,Quit,Click to close... DIALOG ADD,BUTTON,OSInfo_btn,184,180,64,24,OSInfo,Click for OS information... DIALOG ADD,BUTTON,IPConfig_btn,208,96,64,24,IPConfig,Click for the IP configurations... DIALOG ADD,BUTTON,Rename_btn,208,264,64,24,Rename,Click to rename the computer... DIALOG ADD,BUTTON,Reboot_btn,228,180,64,24,Reboot,Click to reboot the computer... DIALOG ADD,BUTTON,SetIP_btn,244,92,76,24,SetIP,Click to Set the IP address info... DIALOG ADD,BUTTON,EnableDHCP_btn,244,260,72,24,Enable DHCP,Click to enable DHCP DIALOG ADD,BUTTON,EnableDNS_btn,280,96,64,24,Set DNS,Click to configure DNS settings... DIALOG ADD,BUTTON,EnableWINS_btn,280,264,64,24,Set WINS,Click to configure WINS... Dialog Show #Disable all the other controls until we login with WMI Dialog Disable,IPConfig_btn Dialog Disable,Rename_btn Dialog Disable,OSInfo_btn Dialog Disable,SetIP_btn Dialog Disable,EnableDHCP_btn Dialog Disable,Reboot_btn Dialog Disable,EnableDNS_btn Dialog Disable,EnableWINS_btn # Now here is a neat trick # Browse the Windows Network of all Windows Workgroups and Domains List Assign,Domain_cbo,@GetRootNetList() If @Greater(@count(Domain_cbo),0) # if we got our list of domains try to goto the local Domain %%Seektolocal = @Match(Domain_cbo,%%LocalDomainName) If %%Seektolocal List Seek,Domain_cbo,@Index(Domain_cbo) %%NewDomain = @dlgtext(Domain_cbo) If %%NewDomain %%Seektolocal = List Assign,Computer_cbo,@GetComputerList(%%NewDomain) If @Greater(@count(Computer_cbo),0) %%Seektolocal = @Match(Computer_cbo,%%LocalComputerName) If %%Seektolocal List seek,Computer_cbo,@Index(Computer_cbo) Else List Add,Computer_cbo,%%LocalComputerName %%Seektolocal = @Match(Computer_cbo,%%LocalComputerName) List seek,Computer_cbo,@Index(Computer_cbo) End End End Else List Add,Domain_cbo,%%LocalDomainName %%Seektolocal = @Match(Domain_cbo,%%LocalDomainName) List Seek,Domain_cbo,@Index(Domain_cbo) %%NewDomain = @dlgtext(Domain_cbo) If %%NewDomain %%Seektolocal = List Assign,Computer_cbo,@GetComputerList(%%NewDomain) If @Greater(@count(Computer_cbo),0) %%Seektolocal = @Match(Computer_cbo,%%LocalComputerName) If %%Seektolocal List seek,Computer_cbo,@Index(Computer_cbo) Else List Add,Computer_cbo,%%LocalComputerName %%Seektolocal = @Match(Computer_cbo,%%LocalComputerName) List seek,Computer_cbo,@Index(Computer_cbo) End End End End End %%OldDomain = :evloop wait event,0.3 goto @event() :TIMER goto evloop :Domain_cboCLICK %%objWMIService = Dialog Disable,IPConfig_btn Dialog Disable,Rename_btn Dialog Disable,OSInfo_btn Dialog Disable,SetIP_btn Dialog Disable,EnableDHCP_btn Dialog Disable,Reboot_btn Dialog Disable,EnableDNS_btn Dialog Disable,EnableWINS_btn %%NewDomain = @dlgtext(Domain_cbo) if %%NewDomain If @Equal(%%NewDomain,%%LocalDomainName) %%Seektolocal = List Assign,Computer_cbo,@GetComputerList(%%NewDomain) If @Greater(@count(Computer_cbo),0) %%Seektolocal = @Match(Computer_cbo,%%LocalComputerName) If %%Seektolocal List seek,Computer_cbo,@Index(Computer_cbo) Else List Add,Computer_cbo,%%LocalComputerName %%Seektolocal = @Match(Computer_cbo,%%LocalComputerName) List seek,Computer_cbo,@Index(Computer_cbo) End End Else List Assign,Computer_cbo,@GetComputerList(%%NewDomain) If @Greater(@count(Computer_cbo),0) List seek,Computer_cbo,0 End End End goto evloop :Computer_cboCLICK %%objWMIService = Dialog Disable,IPConfig_btn Dialog Disable,Rename_btn Dialog Disable,OSInfo_btn Dialog Disable,SetIP_btn Dialog Disable,EnableDHCP_btn Dialog Disable,Reboot_btn Dialog Disable,EnableDNS_btn Dialog Disable,EnableWINS_btn goto evloop :Login_btnBUTTON If %%objWMIService CleanUp End #replace the parameters with the correct info for your network %%UserName = @dlgtext(UserName_edt) %%Password = @dlgtext(Password_edt) %%ComputerName = @dlgtext(Computer_cbo) %%DomainWorkgroup = @dlgtext(Domain_cbo) %%objWMIService = @WMILogin(%%DomainWorkgroup,%%ComputerName,%%UserName,%%Password) If %%objWMIService Dialog Enable,IPConfig_btn Dialog Enable,Rename_btn Dialog Enable,OSInfo_btn Dialog Enable,SetIP_btn Dialog Enable,EnableDHCP_btn Dialog Enable,Reboot_btn Dialog Enable,EnableDNS_btn Dialog Enable,EnableWINS_btn Else %A = Test repeat %A = @GetLastError() If %A Warn %A End Until @Null(%A) End goto evloop :IPConfig_btnBUTTON %Q = If %%objWMIService %Q = @IPConfig(%%objWMIService) Info %Q@CR() List clear,9 List Assign,9,%Q %%OldSep = @fsep() Option FieldSep,= Parse "%%Name;%%NumAdapters",@Item(9,1) List Clear,8 %%cnt = 0 repeat If @Match(9,Network AdapterId) Parse "%%Name;%%AdapterId",@Item(9) List Add,8,@Trim(%%AdapterId) End %%cnt = @Succ(%%cnt) Until @Equal(%%cnt,%%NumAdapters)@Greater(%%cnt,%%NumAdapters) Option FieldSep,%%OldSep End goto evloop :OSInfo_btnBUTTON If %%objWMIService Info @GetOSInfo(%%objWMIService)@CR() End goto evloop :Rename_btnBUTTON If %%objWMIService %%NewName = @Input(Please enter a new name for @dlgtext(Computer_cbo),@dlgtext(Computer_cbo)) If @OK() %%NewDescription = @Input(Please enter a new Description for %%NewName) If @Not(@OK()) %%NewDescription = %%Description End %Q = @ReNameComputer(%%objWMIService,%%NewName,%%NewDescription,%%UserName,%%Password) %%OldSep = @fsep() PARSE "%%Name;%%Description",%Q Option FieldSep,@CR() Info The name %%Name and description %%Description@CR()has been changed to %%NewName and %%NewDescription. Option FieldSep,%%OldSep End End goto evloop :SetIP_btnBUTTON #SetIP(AdapterId,IpAddresses,subnetmasks,gatewayips) If @Ask(Are you sure you want to change your IP Addresses to this scripts hardcoded values) If %%objWMIService %%IpAddresses = 192.168.1.2@CR()192.168.1.3@cr() %%SubNetMasks = 255.255.255.0@CR()255.255.255.0@cr() %%GateWayIps = 192.168.1.1@CR()@CR() %%AdapterId = @Item(8,0) if @Greater(%%AdapterID,0) %Q = @SetIP(%%objWMIService,%%AdapterId,%%IpAddresses,%%SubNetMasks,%%GateWayIps) #%Q can be one of the following errorcodes.... #0 Successful completion, no reboot required. #1 Successful completion, reboot required. #64 Method not supported when the NIC is in DHCP mode. #65 Unknown failure. #66 Invalid subnet mask. #67 An error occurred while processing an instance that was returned. #68 Invalid input parameter. #69 More than five gateways specified. #70 Invalid IP address. #71 Invalid gateway IP address. #72 An error occurred while accessing the registry for the requested information. #73 Invalid domain name. #74 Invalid host name. #75 No primary or secondary WINS server defined. #76 Invalid file. #77 Invalid system path. #78 File copy failed. #79 Invalid security parameter. #80 Unable to configure TCP/IP service. #81 Unable to configure DHCP service. #82 Unable to renew DHCP lease. #83 Unable to release DHCP lease. #84 IP not enabled on adapter. #85 IPX not enabled on adapter. #86 Frame or network number bounds error. #87 Invalid frame type. #88 Invalid network number. #89 Duplicate network number. #90 Parameter out of bounds. #91 Access denied. #92 Out of memory. #93 Already exists. #94 Path, file, or object not found. #95 Unable to notify service. #96 Unable to notify DNS service. #97 Interface not configurable. #98 Not all DHCP leases can be released or renewed. #100 DHCP not enabled on adapter. If @Zero(%Q) Info Your IP addresses have been set for Adapter %%AdapterId@Cr() Elsif @Equal(%Q,1) If @Ask(Your PC needs to reboot to complete the changes?) goto Reboot_btnBUTTON End Else Error %Q End End End End Goto evloop :EnableDHCP_btnBUTTON If @Ask(Are you sure you want to enable DHCP. You will loose your current IP config.) If %%objWMIService %Q = @SetDHCP(%%objWMIService,%%AdapterId) If @Zero(%Q) Info DHCP is Enabled. ElsIf @Equal(%Q,1) If @Ask(Your PC needs to reboot to complete the changes?) goto Reboot_btnBUTTON End Else Error %Q End End End Goto evloop :Reboot_btnBUTTON If @Ask(Are you sure you want to Reboot your computer) If %%objWMIService %%Logoff = 0 %%ForceLogoff = 4 %%Shutdown = 1 %%ForceShutdown = 5 %%Reboot = 2 %%ForceReboot = 6 %%Powerdown = 8 %%ForcePowerdown = 12 %Q = @ShutDownComputer(%%objWMIService,%%Reboot) If @Zero(%Q) Info Click Ok to finish shuting down your computer. Else Info Could not reboot the computer@CR()returned error %Q End End End Goto evloop :EnableDNS_btnBUTTON Info Not implemented yet. Goto evloop :EnableWINS_btnBUTTON Info Not implemented yet. Goto evloop :Cancel_btnBUTTON :CLOSE UnInitNetConfig Exit
:End of NetworkConfig