Seite 1 von 1
Erledigt! Schreib- + Leserechte unter Windows 11
Verfasst: 01.08.2025 20:01
von EmmJott
Hallo @ all!
kann mirjemand sagen, wie man für ein bestimmtes Verzeichnis und dessen Unterverzeichnisse (und aller darin enthaltenen Dateien) Schreib- und Leserechte für den User prüft und ggf. entsprechend einstellt?
Re: Schreib- + Leserechte unter Windows 11
Verfasst: 01.08.2025 21:21
von mk-soft
Am besten garnicht.
Hierfür gibt es spezielle Ordner und regeln wo der Benutzer drauf zugreifen darf
Es sollten auch keine Dateien in den Programm Ordner geschrieben werden, da ein Normaler Benutzer keine Rechte dort hat.
Code: Alles auswählen
;-TOP
; Comment : Path Helper v1.04.2 by mk-soft
; Link : https://www.purebasic.fr/english/viewtopic.php?p=562634#p562634
; Change names
CompilerIf Defined(CompanyName, #PB_Constant) = 0
#CompanyName = "mk-soft"
CompilerEndIf
CompilerIf Defined(ApplicationName, #PB_Constant) = 0
#ApplicationName = "MyApplication"
CompilerEndIf
; ----
CompilerIf #PB_Compiler_OS
Macro CocoaString(NSString)
PeekS(CocoaMessage(0, NSString, "UTF8String"), -1, #PB_UTF8)
EndMacro
CompilerEndIf
Procedure.s GetProgramPath()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Static bundlePath.s
Protected bundlePathPtr
If Not Bool(bundlePath)
bundlePathPtr = CocoaMessage(0,CocoaMessage(0,0,"NSBundle mainBundle"),"bundlePath")
If bundlePathPtr
bundlePath = CocoaString(bundlePathPtr) + "/"
EndIf
EndIf
ProcedureReturn bundlePath
CompilerElse
ProcedureReturn GetPathPart(ProgramFilename())
CompilerEndIf
EndProcedure
; ----
Procedure.s GetResourcePath()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Static resourcePath.s
Protected resourcePathPtr
If Not Bool(resourcePath)
resourcePathPtr = CocoaMessage(0,CocoaMessage(0,0,"NSBundle mainBundle"),"resourcePath")
If resourcePathPtr
resourcePath = CocoaString(resourcePathPtr) + "/"
EndIf
EndIf
ProcedureReturn resourcePath
CompilerElse
ProcedureReturn GetProgramPath() + "Resources" + #PS$
CompilerEndIf
EndProcedure
; ----
Procedure.s GetLibraryPath()
Protected librayPath.s
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
librayPath = GetProgramPath() + "Contents/Library/"
CompilerElse
librayPath = GetProgramPath() + "Library" + #PS$
CompilerEndIf
ProcedureReturn librayPath
EndProcedure
; ----
Procedure.s GetProgramDataPath()
Protected basePath.s, subPath.s, dataPath.s
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
basePath = GetHomeDirectory()
subPath = basePath + "." + #CompanyName + #PS$
CompilerElse
basePath = GetUserDirectory(#PB_Directory_ProgramData)
subPath = basePath + #CompanyName + #PS$
CompilerEndIf
dataPath = subPath + #ApplicationName + #PS$
If FileSize(dataPath) <> -2
If FileSize(subPath) <> -2
CreateDirectory(subPath)
EndIf
If FileSize(dataPath) <> -2
CreateDirectory(dataPath)
EndIf
EndIf
ProcedureReturn dataPath
EndProcedure
; ----
Procedure.s GetAllUserDataPath()
Protected basePath.s, subPath.s, dataPath.s
basePath = GetUserDirectory(#PB_Directory_AllUserData)
subPath = basePath + #CompanyName + #PS$
dataPath = subPath + #ApplicationName + #PS$
If FileSize(dataPath) <> -2
If FileSize(subPath) <> -2
CreateDirectory(subPath)
EndIf
If FileSize(dataPath) <> -2
CreateDirectory(dataPath)
EndIf
EndIf
ProcedureReturn dataPath
EndProcedure
; ****
CompilerIf #PB_Compiler_IsMainFile
Debug "Program Path: " + GetProgramPath()
Debug "Program Resources Path: " + GetResourcePath()
Debug "Program Libraries Path: " + GetLibraryPath()
Debug "Program Data Path: " + GetProgramDataPath()
Debug "Program Alluser Data Path: " + GetAllUserDataPath()
CompilerEndIf
Re: Schreib- + Leserechte unter Windows 11
Verfasst: 02.08.2025 11:20
von Axolotl
Ich brauche das zwar nicht, weil ich es so ähnlich mache wie mk-soft geschrieben hat.
Vielleicht hilft Dir das folgende weiter:
Übersicht über die Zugriffssteuerung von M$
1. Mit einem Kommandozeilen-Tool:
2. oder Powershell:
3. Englisches Forum:
Get Process Owner, & Permissions [Win_Func]
Falls du gerne englische Texte ließt (oder DeepL bemühen möchtest):
Safety in Windows
Re: Schreib- + Leserechte unter Windows 11
Verfasst: 08.08.2025 16:16
von EmmJott
Danke für die Hinweise. Da sich Windows dazu entschlossen hat, mich doch nicht mehr zu ärgern (zeitweise scheinbar zufällig wechselnde Zugriffsrechte für Ordner im User-Verzeichnisbaum), will ich lieber mal den Ratschlag befolgen und nicht daran rumzimmern.