示例#1
0
def CheckAdminRun():
    if not appconstants.AppUACAdmin or UserIsAdmin():
        # if admin not needed or already admin ... go ahead
        return True, None

    if not appconstants.appisfrozen() or sys.platform != 'win32':
        # Manifest cannot be used if not frozen or in unix-like systems
        return RunAsAdmin()
    elif not appconstants.AppUACManifest:
        # frozen and win32 ... and no manifest
        return RunAsAdmin()
    else:
        # frozen win32 ... and manifest
        # we "must" be running as Admin, becasue if not the application
        # would not have started
        # (or else ... a bug in the manifest or embedding process has acted)
        return False, 'Unknown error. Manifest must request Administrator permissions before launch'
示例#2
0
def CheckAdminRun():
    if not appconstants.AppUACAdmin or UserIsAdmin():
        # if admin not needed or already admin ... go ahead
        return True, None

    if not appconstants.appisfrozen() or sys.platform != 'win32':
        # Manifest cannot be used if not frozen or in unix-like systems
        return RunAsAdmin()
    elif not appconstants.AppUACManifest:
        # frozen and win32 ... and no manifest
        return RunAsAdmin()
    else:
        # frozen win32 ... and manifest
        # we "must" be running as Admin, becasue if not the application
        # would not have started
        # (or else ... a bug in the manifest or embedding process has acted)
        return False, 'Unknown error. Manifest must request Administrator permissions before launch'
示例#3
0
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import appconstants
import os
import os.path
import pywintypes
import time
import sys

if not appconstants.appisfrozen() and sys.platform == 'win32':
    # PyInstaller 3.0 (2015-10-27) cannot cope win32com.shell.shell
    # Import the modules below only if app is not frozen and win32
    # For an already built-in binary ... the manifest must be used
    import win32con
    import win32com.shell.shell
    import win32com.shell.shellcon

CheckRunAdminError = '''
Error, This application should be running as Administrator via
the embedded manifest.xml, but it is not.

The application needs administrator permissions to run.
'''

示例#4
0
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
import appconstants
import os
import os.path
import pywintypes
import time
import sys

if not appconstants.appisfrozen() and sys.platform == 'win32':
    # PyInstaller 3.0 (2015-10-27) cannot cope win32com.shell.shell
    # Import the modules below only if app is not frozen and win32
    # For an already built-in binary ... the manifest must be used
    import win32con
    import win32com.shell.shell
    import win32com.shell.shellcon

CheckRunAdminError = '''
Error, This application should be running as Administrator via
the embedded manifest.xml, but it is not.

The application needs administrator permissions to run.
'''