Pfad zum "Default User" Profile finden

  • Hallo,

    ich mache mir gerade ein Installationsscript für QuickTime 7.5.5. Dabei muss eine Datei in das Verzeichnis

    Code
    %SystemDrive%\Documents and Settings\Default User\Application Data\Apple Computer\QuickTime\


    kopiert werden. Wobei der Pfad-Teil "Documents and Settings" sprachabhängig ist (d. h. von der installierten XP Basissprache abhängt)

    Leider gibt es anscheinend kein Makro für den Default User bzw. dessen Pfade, daher habe ich mir eine Funktion geschrieben:

    Ich denke, dass es da sicher noch etwas Optimierungspotenzial gibt... :rolleyes: oder einen anderen, geschickteren Weg (der Check auf "PrintHood" gefällt mir persönlich nicht so sehr...)

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

    Einmal editiert, zuletzt von ahe (11. September 2008 um 13:12)

  • Hallo Tweaky,

    das hatte ich zuerst auch gedacht, allerdings verweist das auf das "All Users" Verzeichnis (s. Codebeispiel) ... :rolleyes:

    Code
    $systempathes= "@StartMenuCommonDir: " &@TAB & @StartMenuCommonDir & @CRLF _ 
    				& "@AppDataCommonDir: " &@TAB & @AppDataCommonDir & @CRLF _ 
    				& "@AppDataDir: " &@TAB&@TAB& @AppDataDir & @CRLF _
    				& "@CommonFilesDir: " &@TAB&@TAB& @CommonFilesDir _
    
    
    MsgBox(0, "Diverse Pfade...", $systempathes)

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

    • Offizieller Beitrag

    Ähem...

    [autoit]

    @AppDataDir

    [/autoit]

    verweist bei mir auf:
    C:\Dokumente und Einstellungen\Oscar\Anwendungsdaten\

    also auf den angemeldeten User und nicht All Users.


    Edit: Oh, Sorry! Default User!
    Hab's nicht richtig gelesen.

    Edit2: Wie wäre es mit dieser Lösung:

    [autoit]

    MsgBox(0, "Default User path...", StringReplace(@AppDataDir, @UserName, "Default User"))

    [/autoit]
  • Hallo Oscar

    danke, das ist auf jeden Fall eine deutlich kürzere und schnellere Lösung... :)

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

  • Hallo RR04,

    danke Dir, allerdings zeigt mir der Parameter @UserProfileDir das Profile des angemeldeten Benutzers, nicht aber das Verzeichnis des Default Users.

    Die Lösung von Oscar funktioniert und habe ich inzwischen in mein Skript eingebaut (s. Link im letzten Post)

    Kleine Übersicht über die Parameter:

    [autoit]

    $systempathes= "@StartMenuCommonDir: " &@TAB & @StartMenuCommonDir & @CRLF _
    & "@AppDataCommonDir: " &@TAB & @AppDataCommonDir & @CRLF _
    & "@AppDataDir: " &@TAB&@TAB& @AppDataDir & @CRLF _
    & "@CommonFilesDir: " &@TAB&@TAB& @CommonFilesDir & @CRLF _
    & "@UserProfileDir:" &@TAB&@TAB& @UserProfileDir _

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0, "Diverse Pfade...", $systempathes)

    [/autoit]

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

  • Hallo RR04,

    es geht nicht darum, dass ich das Script nicht ausführen kann. Es ging mir einfach darum etwas in das "Default User" Profle zu kopieren. Einstellungen, Dateien, etc. an diesem Profile werden bei der Anmeldung in das Anwenderprofile kopiert!

    Jetzt ist es aber sprachabhängig, wo die Profiles gespeichert werden, daher mußte ich den Pfad ermitteln. Da es weder bei MS eine Umgebungsvariable noch bei AutoIt ein Makro dafür gibt, hatte ich mir eine Funktion gebastelt.
    Oscar hat das dann auf eine Zeile "reduziert" :)

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

  • Hallo Oscar,

    habe ich eigentlich das Script an den richtigen Ort kopiert? Ich hatte nur "Installationsskripte" gelesen (den Titel IOM 3 habe ich wohl "ignoriert")... oder kommt es zu "AutoIt - Skripte"...

    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

  • Die beste Lösung wäre immer noch die Werte aus der Registry zu holen :)

    Spoiler anzeigen
    [autoit]

    ; Prog@ndy
    Func _GetProfilesDirectory()
    Local $path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","ProfilesDirectory")
    Return _WinAPI_DoEnvironmentSubst($path)
    EndFunc
    ; Prog@ndy
    Func _GetDefaultUserProfile()
    Return RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","DefaultUserProfile")
    EndFunc
    ; Prog@ndy
    Func _GetAllUserProfile()
    Return RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","AllUsersProfile")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ; Prog@ndy
    Func _WinAPI_DoEnvironmentSubst($sString)
    Local $tText, $aResult

    [/autoit] [autoit][/autoit] [autoit]

    $tText = DllStructCreate("char Text[260]")
    DllStructSetData($tText,1,$sString)
    $aResult = DllCall("shell32.dll", "int", "DoEnvironmentSubst", "ptr", DllStructGetPtr($tText), "uint", 260)

    [/autoit] [autoit][/autoit] [autoit]

    If @error Or $aResult[0] = 0 Then Return SetError(1,0,"")
    Return DllStructGetData($tText, "Text")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0, 'Profile Dir', _GetProfilesDirectory())
    MsgBox(0, 'DEfault User', _GetDefaultUserProfile())
    MsgBox(0, 'All Users', _GetAllUserProfile())

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(0, 'Def User Full Path', _GetProfilesDirectory() & "\" & _GetDefaultUserProfile() & "\")

    [/autoit]
  • Danke progandy,

    ich habe zwar nicht Alles verstanden (die Funktion _WinAPI_DoEnvironmentSubst($sString) ist mir noch ein Rätsel), aber diese Registryeinträge habe ich eigentlich gesucht... :D

    Könnte dies dann nicht auch reichen:

    [autoit]


    MsgBox(0, "der pfad: ", RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","ProfilesDirectory") _
    & "\" & RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","DefaultUserProfile"))

    [/autoit]


    mfg
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.

  • _WinAPI_DoEnvironmentSubst wird benötigt.
    es übersetzt z.B. %SystemDrive% in den richtigen Pfad, bei mir C:\, bei anderen z.B. D:\
    und mit Funktionen ist es einfach übersichtlicher ;)

  • Hallo progandy,

    heißt das dann, dass %SystemDrive% beim Aufruf meiner EXE ggfs. gar nicht aufgelöst wird und damit die EXE nicht gefunden wird?

    Mmh, kurze Antwort: Ja, habe es jetzt ausprobiert, bevor ich die Frage abschickte...

    Nur wenn ich z. B. einen Aufruf mit Run(@ComSpec & " /c " & 'commandName'... machen würde, könnte ich in den Parametern zum "Command" die OS Umgebungsvariable nutzen.

    Also werde ich wohl Deine Funktion verwenden (wenn ich die Funktion verstanden habe) oder bei Oscars Workaround bleiben... denke ich 'mal drüber nach...
    (habe gerade die Info erhalten, dass ggfs. meine Pakete auch unter XP 64 Bit laufen sollen, ;( da müßte ich dann wohl noch ein paar checks einfügen, STÖHN...)

    Danke.
    Axel

    There exist 10 different kind of people on earth.
    Those who understand binary, and those who don't.