API Access to License Manager Client?

Programming and macros
revenki
Posts: 24
Joined: Fri Sep 24, 2021 11:17 pm
Answers: 0
x 7

API Access to License Manager Client?

Unread post by revenki »

We have a limited number of licenses, can't buy any more at the moment, and so occasionally have all licenses in use when someone needs one.

One can go to the license manager client, see who has a license, and send them an email or chat requesting they release their license, entering each name manually.

I want to make a script to do this in pushbutton fashion. Can't get a license? Run the script, all current license holders get a message requesting they free up a license if they can.

But I don't know where to look in the API for such a thing, and don't even know if it's possible. How can I read who currently has a license, if I can in fact do so? I've done a lot of SW and PDM scripting, so I should be able to figure it out if I just know where to look.
Berickson
Posts: 5
Joined: Thu Apr 08, 2021 10:07 am
Answers: 1
x 18
x 7

Re: API Access to License Manager Client?

Unread post by Berickson »

I have used lmutil in a command prompt to get license usage including who is using it. You could run that and parse out the users.

You can run this here if you have SolidWorks 2021 installed:
"C:\Program files\Common Files\SOLIDWORKS Shared\2021\lmutil" lmstat -a -c 25734@<license server name goes here>

These are just flexnet license commands. You can Google Flexnet admin guides to get more information on the available parameters.
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2544
x 1400

Re: API Access to License Manager Client?

Unread post by bnemec »

The method I used to log license usage is a C# application/service that embeded the lmutil.exe as a resource (it's very small) then placed it in a folder, runs it with args for server and lmstat command and parses the output. It runs twice, once against our SE license server and then against the SW license server. I would have no idea how to write a script to do that. I can go get some snippets of what I did you want. Not saying it's the best way to go about it,
revenki
Posts: 24
Joined: Fri Sep 24, 2021 11:17 pm
Answers: 0
x 7

Re: API Access to License Manager Client?

Unread post by revenki »

Ah, I see what you're doing. I think I can work with that. Thanks!
User avatar
bnemec
Posts: 1944
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2544
x 1400

Re: API Access to License Manager Client?

Unread post by bnemec »

revenki wrote: Fri Dec 02, 2022 4:48 pm Ah, I see what you're doing. I think I can work with that. Thanks!
I was in VS today so opened up this project. Here's a snippet of the class.

Code: Select all

  public class LMTool
  {
    private string lmutils_exePath;

    public LMTool()
    {
      /*lmutil.exe is a tiny executable that we need to run to get the status of the licenses.
       * I don't know if this is the best way to do it, but I added the .exe file as a resourse 
       * in the project then regurgitate it to file on disc so it can be called.  The .exe file
       * should be deleted when the destructor is called.
      */
      lmutils_exePath = Path.Combine(Path.GetTempPath(), "lmutil.exe");
      File.WriteAllBytes(lmutils_exePath, LM_Tools.Properties.Resources.lmutil);

    }

    ~LMTool()
    {
      if (File.Exists(lmutils_exePath))
      {
        File.Delete(lmutils_exePath);
      }
    }
I had commented links to a couple MS docs:

https://docs.microsoft.com/en-us/previo ... dfrom=MSDN

https://docs.microsoft.com/en-us/previo ... 3dvs.90%29
Post Reply