Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you check leasingmode setting through the program?

Vince Wen

Programmer
Jun 15, 2024
28
HK
Is there a way to query SMB share leasing mode directly through the program? To be clear, I don't want to do this through a powershell script, as there are permissioning issues around this (simply put, I don't have the permission).

I've dug around quite a bit and I think the answer is no. But wanted to double check.

If so, is there a creative way to trigger oplocks then check if 'file access is denied' to indirectly determine if leasingmode is set to none?
 
I think you're trying to tackle this from the wrong side. It's in the interest of the users you don't have oplock problems on their LAN, so make it a requirement of your software to establish the leasing mode settting, otherwise you'll not warrant for the flawless working of your software. There's nothing to be sneaky about. Software requirements are nothing special, if there's othe requirements like minimum RAM, mimimum disk space, they also can't insist on not fulfilling them, if they want to use that software.
 
Last edited:
Thanks Chriss. The reason for the question is - my users are not technically savvy and I've noticed that most network admins don't know what oplocks/leasingmode is. So I was trying to figure out a way to check this automatically (nothing sneaky) and provide instructions if and when needed.
 
Well, you know the powershell commandlet to use, don't you? That's what you can provide for their admins to run.

If you even have customers in a small company without anyone that has depper IT knowledge, then doing that within a setup should be a solution.
Here's a thread about that within an Inno Setup:

Notice the elevated nature of a setup allows to use the -ExecutionPolicy Bypass switch for the execution of powershell when it's by default disabled to run scripts. Remember you have to do things in setup when they are requiring elevation, as that's usually the only situation you can do that.
 

Part and Inventory Search

Sponsor

Back
Top