Skip to main content

[archive] Local Machine Name

  • July 23, 2009
  • 4 replies
  • 0 views

[Migrated content. Thread originally posted on 22 July 2009]

I know this question that may have been asked before but I could not find it. I need to know how to get the local machine name when running on with a windows runtime.

I use the terminal-info to get the client-machine-name when running thin client, but this field is blank on a windows runtime since there are no terminal abilities. I have a file that keeps track of the machines which accessed a file and at what time. I have everything I need when running thin client but not on windows. Any help would be greatly appreciated.

4 replies

[Migrated content. Thread originally posted on 22 July 2009]

I know this question that may have been asked before but I could not find it. I need to know how to get the local machine name when running on with a windows runtime.

I use the terminal-info to get the client-machine-name when running thin client, but this field is blank on a windows runtime since there are no terminal abilities. I have a file that keeps track of the machines which accessed a file and at what time. I have everything I need when running thin client but not on windows. Any help would be greatly appreciated.
I think something like the following should work for you:


01 WS-COMPNAME      PIC X(60).
01 WS-SIZE               PIC X(4) COMP-N. 

SET ENVIRONMENT "DLL_CONVENTION" TO 1.
CALL "kernel32.dll".
MOVE SPACES TO WS-COMPNAME.
SET WS-SIZE TO SIZE OF WS-COMPNAME.
CALL "GetComputerNameA" USING
         BY REFERENCE WS-COMPNAME
         BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-COMPNAME REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "kernel32.dll".

[Migrated content. Thread originally posted on 22 July 2009]

I know this question that may have been asked before but I could not find it. I need to know how to get the local machine name when running on with a windows runtime.

I use the terminal-info to get the client-machine-name when running thin client, but this field is blank on a windows runtime since there are no terminal abilities. I have a file that keeps track of the machines which accessed a file and at what time. I have everything I need when running thin client but not on windows. Any help would be greatly appreciated.
I think something like the following should work for you:


01 WS-COMPNAME      PIC X(60).
01 WS-SIZE               PIC X(4) COMP-N. 

SET ENVIRONMENT "DLL_CONVENTION" TO 1.
CALL "kernel32.dll".
MOVE SPACES TO WS-COMPNAME.
SET WS-SIZE TO SIZE OF WS-COMPNAME.
CALL "GetComputerNameA" USING
         BY REFERENCE WS-COMPNAME
         BY REFERENCE WS-SIZE
END-CALL.
INSPECT WS-COMPNAME REPLACING ALL LOW-VALUES BY SPACES.
CANCEL "kernel32.dll".

[Migrated content. Thread originally posted on 22 July 2009]

I know this question that may have been asked before but I could not find it. I need to know how to get the local machine name when running on with a windows runtime.

I use the terminal-info to get the client-machine-name when running thin client, but this field is blank on a windows runtime since there are no terminal abilities. I have a file that keeps track of the machines which accessed a file and at what time. I have everything I need when running thin client but not on windows. Any help would be greatly appreciated.
We have 2 Versions how Users can work.
Inhouse or Remote (RDP-Connection)...

Windows set Environment-Variables for Clientname and Computername which you can accept.

77 env-clientname pic x(15) value spaces.
77 env-compname pic x(15) value spaces.


accept env-clientname from environment "CLIENTNAME".
accept env-compname from environment "COMPUTERNAME".

if env-compname(1:3) = "SRV"
move env-clientname to env-compname.


All Terminal-Servers begin with "SRV" (our intern naming convention) so i know that i must use the Clientname as Computername.

If the users work Inhouse the Clientname is always blank (spaces).

[Migrated content. Thread originally posted on 22 July 2009]

I know this question that may have been asked before but I could not find it. I need to know how to get the local machine name when running on with a windows runtime.

I use the terminal-info to get the client-machine-name when running thin client, but this field is blank on a windows runtime since there are no terminal abilities. I have a file that keeps track of the machines which accessed a file and at what time. I have everything I need when running thin client but not on windows. Any help would be greatly appreciated.
Thanks for your suggestions, both worked great. We decided to use the accept from the environment.