How do I return the current "machine name" within Windows XP?
With Windows XP a user may set a "machine name" for Network ID etc.... This may affect the way that
certain scripts execute, and how objects are recognised; which can require a separate include file.
In order to aid the automation of selecting the correct include file or update variables to the current machine
name, it is necessary to be able to determine what the machine name is at any given time.
This can be achieved by querying a specific registry entry within the windows registry file.
The following script queries this entry and then determines the machine name upon which the current
operations are being executed.
The result is then printed to the results file.
[ ] //Code [ ] use "msw32.inc" [ ] [-] testcase ComputerName () appstate none [ ] //Get regvalue for reg entry: HKEY_CURRENT_USER\Software\Microsoft\WindowsMedia\WMSDK\General [ ] //\Software\Microsoft\Windows Media\WMSDK\General [ ] [ ] [ ] //RegKey value for ComputerName [ ] //ComputerName is the current name returned for this computer. [ ] [ ] INTEGER iKey = HKEY_CURRENT_USER // defined in msw32.inc [ ] STRING sPath = "Software\Microsoft\Windows Media\WMSDK\General\" [ ] String sItem = "ComputerName" [ ] String sCurrentTheme = "" [ ] [ ] [ ] String sRegValue = SYS_GetRegistryValue (iKey, sPath, sItem) [ ] //Print (SYS_GetRegistryValue (iKey, sPath, sItem)) [ ] [ ] Print("The current Computer Name is: ",sRegValue) [ ] //End Code