IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Lancer un fichier *.cmd (dos) pour modifier Regedit sous Seven 64bits !


Sujet :

Delphi

  1. #1
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 426
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 426
    Points : 1 326
    Points
    1 326
    Par défaut Lancer un fichier *.cmd (dos) pour modifier Regedit sous Seven 64bits !
    Bonjour à toutes et à tous,

    J'aimerai dans le cas ou les clés contenues dans mon fichier *.cmd sont disabled, les mettre à enabled avec une commande dos et droits administrateurs bien entendu.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
     
    function ExecuteCommande(Commande: String;Attente : Boolean = True): Boolean;
    Var
      lpsaProcess,
      lpsaThread    : PSecurityAttributes;
      StartupInfo   : TStartupInfo;
      ProcessInfo   : TProcessInformation;
      AddrCmd       : Array [0..255] Of Char;
      ExitCode      : DWord;
    begin
      FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
      with StartupInfo do
      begin
        cb          := SizeOf(TStartupInfo);
        dwFlags     := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
        wShowWindow := SW_HIDE;
      end;
     
      New(lpsaProcess);
      New(lpsaThread);
     
      lpsaProcess^.nLength              := SizeOf(lpsaProcess^);
      lpsaProcess^.lpSecurityDescriptor := Nil;
      lpsaProcess^.bInheritHandle       := True;
     
      lpsaThread^.nLength              := SizeOf(lpsaThread^);
      lpsaThread^.lpSecurityDescriptor := Nil;
      lpsaThread^.bInheritHandle       := True;
     
      StrPCopy(AddrCmd, Commande);
      Result := CreateProcess(nil, AddrCmd, lpsaProcess, lpsaThread, False,
                              STARTF_FORCEONFEEDBACK, nil, nil, StartupInfo, ProcessInfo);
      if not Result then Result:=(GetLastError>10000);
      Dispose(lpsaProcess);
      Dispose(lpsaThread);
      if Result then
      begin
        while Attente do
        begin
          // Solution d'attente 1
          Sleep(500);
          GetExitCodeProcess(ProcessInfo.hProcess, ExitCode);
          if ExitCode<>STILL_ACTIVE then break;
     
          // Solution d'attente 2
          // WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
     
        end;
        CloseHandle(ProcessInfo.hThread);
        CloseHandle(ProcessInfo.hProcess);
      end;
    end;
     
     
    function BuildDosCommandStr(Command:string):string;
    begin
        result:='cmd /c "'+Command+'"';
    end;
     
    procedure TForm1.Button8Click(Sender: TObject);
    begin
        ExecuteCommande(BuildDosCommandStr('open chappli monfichier.cmd'),TRUE);
    end;
    Merci de votre attention,

    Cincap

  2. #2
    Expert éminent sénior

    Avatar de sjrd
    Homme Profil pro
    Directeur de projet
    Inscrit en
    Juin 2004
    Messages
    4 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Suisse

    Informations professionnelles :
    Activité : Directeur de projet
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2004
    Messages : 4 517
    Points : 10 154
    Points
    10 154
    Par défaut
    Et qu'est-ce qui ne fonctionne pas, exactement ?
    sjrd, ancien rédacteur/modérateur Delphi.
    Auteur de Scala.js, le compilateur de Scala vers JavaScript, et directeur technique du Scala Center à l'EPFL.
    Découvrez Mes tutoriels.

  3. #3
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 426
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 426
    Points : 1 326
    Points
    1 326
    Par défaut
    @ Sjrd, bonsoir, en fait ma clé ne se modifie pas (bien en manuel en répondant au message d'alerte concernant les droits).

    Est-ce le chemin, le fichier ou la façon de lancer le fichier *.cmd qui se trouve dans le même répertoire que l'application.

    chappli étant une variable de type String et donne le chemin de mon application.

    A tout hasard, voici le contenu de la commande dos :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    echo OFF
     
    REM Forces the use of the custom background permanently
    reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background /v OEMBackground /t REG_DWORD /d 1 /f
    reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\System /v UseOEMBackground /t REG_DWORD /d 1 /f
    @+,

    Cincap

Discussions similaires

  1. Lire valeur dans RegEdit sous Seven !
    Par cincap dans le forum Débuter
    Réponses: 7
    Dernier message: 22/11/2010, 19h28
  2. Fichier Ini sous Seven 64bits !
    Par cincap dans le forum Débuter
    Réponses: 13
    Dernier message: 21/07/2010, 10h03
  3. Réponses: 3
    Dernier message: 26/10/2009, 13h32
  4. Réponses: 24
    Dernier message: 07/12/2005, 10h37
  5. un batch DOS pour "nettoyer des fichiers" ?
    Par RoroMinator dans le forum Scripts/Batch
    Réponses: 9
    Dernier message: 12/02/2004, 16h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo