1. David Vasconcelos
  2. PowerServer 2020 or older (Obsolete)
  3. Thursday, 4 April 2019 16:17 PM UTC

Anyone know how to get the MAC address of the PC the app is running on.  (Note: I have the IP) just need to get the MAC.  I did try the "Get Mac address demo" from the code exchange but one of the numbers in the returning MAC address is coming back wrong.

 

Dave V.

Accepted Answer
Luiz Ribeiro Accepted Answer Pending Moderation
  1. Thursday, 4 April 2019 16:48 PM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # Permalink

Hi Dave.

 

Try this:

 

OLEObject ole_wsh
Any la_usb[]
string ls_message

 ole_wsh = CREATE OLEObject
 ole_wsh.ConnectToNewObject("MSScriptControl.ScriptControl")
 ole_wsh.Language = "vbscript"
 ole_wsh.AddCode('Function rtnMACAddresses()~r~n' &
 + 'MACAddressList = "" ~r~n' + &
 + 'strComputer = "."~r~n' + &
 + 'Set objWMIService = ' + &
 + '   GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _~r~n' &
 + '& strComputer & "\root\cimv2")~r~n' &
 + 'Set colItems = ' &
 + '  objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = ~'TRUE~'")~r~n' &
 + 'For Each objItem in colItems~r~n' &
 + 'MACAddressList = MACAddressList & " | " & objItem.Description & " = " & objItem.MACAddress  ~r~n' &
 + 'Next~r~n' &
 + 'rtnMACAddresses = MACAddressList~r~n' &
 + 'End Function')
 ls_message = ole_wsh.Eval("rtnMACAddresses")
 ole_wsh.DisconnectObject()
 DESTROY ole_wsh

MessageBox("MAC Adress List",ls_message)
Comment
  1. Armeen Mazda @Appeon
  2. Thursday, 4 April 2019 21:04 PM UTC
Do you need your Web app to do this or you just yourself want to get the MAC address to activate your PowerServer license?
  1. Helpful
  1. David Vasconcelos
  2. Friday, 5 April 2019 09:41 AM UTC
Need our web app to get the MAC address, we maybe using it for security reasons.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Friday, 5 April 2019 16:41 PM UTC
I see. It would be getting the MAC address of the client not the server since the Web app runs in the browser at the client. There is no built-in function provided by PowerServer to do this. You would need to write your own code.



It is possible that code snippet is not working because it contains some unsupported features. One option is to create a DLL and call that DLL from your Web app. PowerServer does support external function calls.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 4 April 2019 18:46 PM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 1

Hi David;

   My framework solution also works in PowerServer Web as well. Also, it introspects the Web browser environment for you as well.

For example (run in the Edge browser):

Regards ... Chris

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 4 April 2019 17:22 PM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 2

I have a sample app to list network card info including the MAC and description:

http://www.topwizprogramming.com/freecode_adapter.html

 

Comment
  1. Roland Smith
  2. Thursday, 4 April 2019 19:22 PM UTC
I haven't tested any of my examples in PowerServer. I haven't even tried to use PowerServer.
  1. Helpful
  1. David Vasconcelos
  2. Friday, 5 April 2019 09:40 AM UTC
Thanks Roland.
  1. Helpful
  1. Roland Smith
  2. Friday, 5 April 2019 17:37 PM UTC
Make sure you use the 10.5 version, the 12.6 version may have unsupported features, longptr for example.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 4 April 2019 17:19 PM UTC
  2. PowerServer 2020 or older (Obsolete)
  3. # 3

Hi Guys;

  Its also built into my free framework ... which handles all real, virtual & VM based network adapters, as follows:

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.