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 can SilkTest return the current HostName within Windows XP?

How can SilkTest return the current HostName within Windows XP?

Within Windows XP, a user may set a machine HostName, this is useful in connecting to remote machines etc.

In order to aid the automation of remote tests, it may be necessary to be able to determine what the current host name of the local machine is at runtime. This can be achieved by querying a specific registry entry within the Windows registry.

The following script queries this entry and then determines the machine"s HostName.

The result is then printed to the results file.

[ ] //Borland Code
[ ] use "msw32.inc"
[ ]  
[-] testcase HostName() appstate none
    [ ] //Get regvalue for reg entry: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters [ ] 
    [ ] //RegKey value for Host name
    [ ] //NV Hostname is the current domain returned for this computer.
    [ ] 
    [ ] INTEGER iKey = HKEY_LOCAL_MACHINE // defined in msw32.inc
    [ ] STRING sPath = "SYSTEM\ControlSet001\Services\Tcpip\Parameters\"
    [ ] String sItem = "NV Hostname"
    [ ] String sCurrentTheme = ""
    [ ] 
    [ ] 
    [ ] String sRegValue = SYS_GetRegistryValue (iKey, sPath, sItem)
    [ ] //Print (SYS_GetRegistryValue (iKey, sPath, sItem))
    [ ] 
    [ ] Print("The current Computer Host Name  is: ",sRegValue)
[ ] //End Borland Code

Old KB# 20886


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:14
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.