Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How do I return the current "machine name" within Windows XP?

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

Old KB# 21170

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:17
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.