Python targeting platforms
From wikinotes
General Notes
filesystem
os.path.normpath('/path/to/file') # normalizes path for your osenvironment variables
os.environ['HOME'] >>> /home/willjpkilling a process
pid = os.getpid() os.kill(pid, signal.SIGTERM)
Platforms
Windows
python pyhook python pywin32 python ctypes Verifying User is Windows Admin
Effective: (shows me as non-admin even at home)
NOTE:
Instead of doing this through a console, try checking write access from python itself. Result should be identical)
@echo off REM Calling verify with no args just checks the verify flag, REM we use this for its side effect of setting errorlevel to zero verify >nul REM Attempt to read a particular system directory - the DIR REM command will fail with a nonzero errorlevel if the directory is REM unreadable by the current process. The DACL on the REM c:\windows\system32\config\systemprofile directory, by default, REM only permits SYSTEM and Administrators. dir %windir%\system32\config\systemprofile >nul 2>nul REM Use IF ERRORLEVEL or %errorlevel% to check the result if not errorlevel 1 echo has Admin privs if errorlevel 1 echo has only User privsInneffective: (shows as admin at mercury)
import ctypes admin = ctypes.windll.shell32.IsUserAdmin() != 0