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.
API Access to License Manager Client?
Re: API Access to License Manager Client?
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.
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.
Re: API Access to License Manager Client?
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,
Re: API Access to License Manager Client?
Ah, I see what you're doing. I think I can work with that. Thanks!
Re: API Access to License Manager Client?
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);
}
}
https://docs.microsoft.com/en-us/previo ... dfrom=MSDN
https://docs.microsoft.com/en-us/previo ... 3dvs.90%29