Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1046 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  [VB] démarrge d'un script à chaque démarrage de windows

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[VB] démarrge d'un script à chaque démarrage de windows

n°133291
B0b
Posté le 02-05-2002 à 10:46:34  profilanswer
 

Bonjour !
Je souhaiterais que mon script (destiné à tourner chez un client) démarre en même temps que windows. J'ai trouvé une solution (provisoire car pas très propre) avec un code venant de chez vbfrance : il va recopier MonAppli.exe ds démarrer/programmes/démarrage ...
 
Dans un 'module.bas' j'ai :

Citation :


' déclaration Api
Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
 
'
Type SHITEMID
       cb As Long
       abID As Byte
End Type
 
Type ITEMIDLIST
       mkid As SHITEMID
End Type
 
' constantes
Global Const NOERROR = 0
Global Const PATH_START = 7
 
Public Function CheminDemarrage() As String
Dim RetVal As Long
Dim Path As String    ' déclaration des variables nécessaires
Dim IDL As ITEMIDLIST
    RetVal = SHGetSpecialFolderLocation(0, PATH_START, IDL)  ' appel de la fonction api
    If RetVal = NOERROR Then
        Path = Space(512)  ' taille du tampon
        RetVal = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path)
        CheminDemarrage = Left(Path, InStr(Path, Chr(0)) - 1) ' extraction du chemin
    Else
        CheminDemarrage = ""
    End If
End Function


 
Dans mon formulaire principal j'ai :

Citation :


'Copie de MonAppli.exe dans le répertoire de démarrage automatique
Dim Path As String
Path = CheminDemarrage & "\MonAppli.exe"
FileCopy "MonAppli.exe", Path


 
Quelqu'un aurait-il mieux ?

mood
Publicité
Posté le 02-05-2002 à 10:46:34  profilanswer
 

n°133300
Luluberlu
Posté le 02-05-2002 à 11:07:34  profilanswer
 

As-tu essayé la base de registre ?
Il faut créer une clé dans\\HKEY_LOCAL_MACHINE\Software\microsoft\windows\currentversion\run\
avec le chemin d'accès à to appli.

n°133338
B0b
Posté le 02-05-2002 à 11:45:10  profilanswer
 

Non n'avais pas pensé !
 
Merci bcp pour le coud'main :p


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  [VB] démarrge d'un script à chaque démarrage de windows

 

Sujets relatifs
[C/C++] Dites moi si on peut créer des appz windows[installation sous windows] choisir l'emplacement des dlls malgré tout
SQL Server 7.0 et Windows 2000[PHP] htaccess: récuperer le login dans un script chez free
C et WindowsProbleme avec un script galerie
Besoin d'une liste de departement de france pour mon scriptUn script pour recréer une base RPM (à partir des fichiers) ?
[Perl / CGI] appli web = script CGI + SCPMeilleur Editeur Java sous Windows
Plus de sujets relatifs à : [VB] démarrge d'un script à chaque démarrage de windows


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR