mahelan
Messages postés51Date d'inscriptionmercredi 21 février 2007StatutMembreDernière intervention 4 avril 2007
-
22 févr. 2007 à 19:35
cs_ghuysmans99
Messages postés3982Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 2013
-
3 mars 2007 à 06:52
Bonsoir,
Je voudrais savoir si c'est possible qu'un script.vbs se lance au démarrage?
si oui comment faire?
mahelan
Messages postés51Date d'inscriptionmercredi 21 février 2007StatutMembreDernière intervention 4 avril 2007 23 févr. 2007 à 14:53
Ok,mais je comprend pas
pour un script comme ça c'est un exemple
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("C:\WINDOWS\Tasks\AA8E950191850569.job")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("C:\Documents and Settings\All Users\Application Data\Dent Exit Log Fast")
objFSO.DeleteFolder("C:\Documents and Settings\Thibaud Caquant\Application Data\Once Dog Ace")
objFSO.DeleteFolder("C:\Documents and Settings\Thibaud Caquant\Application Data\BitRoll")
objFSO.DeleteFolder("C:\Program Files\BitRoll")
objFSO.DeleteFolder("C:\Program Files\Once Dog Ace")
Set WshShell = CreateObject("Wscript.Shell")
WshShell.RegDelete"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\log fast hole gram"
WshShell.RegDelete"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ViewMode"
WshShell.RegDelete"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow\netsearchsoft.com"
WshShell.RegDelete"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow\www.netsearchsoft.com"
End With
je veut que quand il clique dessus une boite de dialogue admetons qui fais ce que tu as dit plus haut
puis qui eteint son pc et au démarrage que le script se lance
ce que j'arrive pas c'est la mises en forme de ce script
cs_ghuysmans99
Messages postés3982Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 23 févr. 2007 à 15:18
il y a plus simple que ma méthode : la clé registre HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
il suffit d'ajouter une clé du nom que tu veux et la valeur est le nom de l'exe/script que tu veux lancer !
Public Enum E_Registry_HKey
HKEY_CLASSES_ROOT = 0
HKEY_CURRENT_USER = 1
HKEY_LOCAL_MACHINE = 2
HKEY_USERS = 3
HKEY_CURRENT_CONFIG = 4
End Enum
Public Enum E_Registry_ValueType
REG_SZ = 0
REG_DWORD = 1
REG_BINARY = 2
REG_EXPAND_SZ = 3
End Enum
Public Function RegRead(HKEY As E_Registry_HKey, regpath As String)
Dim WSH As Object
Set WSH = CreateObject("WScript.Shell")
RegRead = WSH.RegRead(GetHKey(HKEY) & "" & regpath)
Set WSH = Nothing
End Function
Public Function RegWrite(HKEY As E_Registry_HKey, regpath As String, RegValue As String, Optional RegValueType As E_Registry_ValueType = REG_SZ)
Dim WSH As Object
Set WSH = CreateObject("WScript.Shell")
WSH.RegWrite GetHKey(HKEY) & "" & regpath, RegValue, GetValueType(RegValueType)
Set WSH = Nothing
End Function
Public Function RegDelete(HKEY As E_Registry_HKey, regpath As String)
Dim WSH As Object
Set WSH = CreateObject("WScript.Shell")
WSH.RegDelete GetHKey(HKEY) & "" & regpath
Set WSH = Nothing
End Function
Private Function GetHKey(HKEY As E_Registry_HKey) As String
Select Case HKEY
Case 0: GetHKey = "HKEY_CLASSES_ROOT"
Case 1: GetHKey = "HKEY_CURRENT_USER"
Case 2: GetHKey = "HKEY_LOCAL_MACHINE"
Case 3: GetHKey = "HKEY_USERS"
Case 4: GetHKey = "HKEY_CURRENT_CONFIG"
End Select
End Function
Private Function GetValueType(VALUETYPE As E_Registry_ValueType) As String
Select Case VALUETYPE
Case 0: GetValueType = "REG_SZ"
Case 1: GetValueType = "REG_DWORD"
Case 2: GetValueType = "REG_BINARY"
Case 3: GetValueType = "REG_EXPAND_SZ"
End Select
End Function
Puis mets tout ce qui est en vert dans un form qui s'appelle frm_prog
Private Sub Form_Load()
Const keyname As String = "Software\Microsoft\Windows\CurrentVersion\RunOnce"
mod_Registry.RegWrite HKEY_CURRENT_USER, keyname & "\LeScriptVBS", "LePathVBS", REG_SZ
End Sub
cs_ghuysmans99
Messages postés3982Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 24 févr. 2007 à 09:40
mod_Registry : c'est un module registre
frm_prog : un form qui va écrire dans "Software\Microsoft\Windows\CurrentVersion\RunOnce" une valeur "LeScriptVBS" qui contiendra "LePathVBS"
OK?
Je l'ai éxécuté chez moi, tu ne crois quand même pas que c'est un truc qui atomise HKEY_CLASSES_ROOT !
mahelan
Messages postés51Date d'inscriptionmercredi 21 février 2007StatutMembreDernière intervention 4 avril 2007 24 févr. 2007 à 14:02
ok sympa,avec ça il se lance au reboot?
y'a moyen que le pc se ferme en cliquand sur ok?
car la il ne s'etteint pas et le script se lance des qu'on clique dessus,il suis pénible désolé
et si à la fin du script on met
WshShell.RegDelete"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce\MonVBS"
comme ça la clé se supprime et evite au script de ce relancer au prochain démarrage?
mahelan
Messages postés51Date d'inscriptionmercredi 21 février 2007StatutMembreDernière intervention 4 avril 2007 24 févr. 2007 à 18:10
Salut,
ça marche effectivement,
petite quéstion:
comment faire pour que le script se lance et donc supprime dans ce cas la que lord du démarrage?
car la il supprime direct des qu'on clique dessus
cs_ghuysmans99
Messages postés3982Date d'inscriptionjeudi 14 juillet 2005StatutMembreDernière intervention30 juin 201316 24 févr. 2007 à 21:09
avant le début, tu mes :
Dim reslt 'As VbMsgBoxResult
reslt = MsgBox("Voulez-vous que ce script supprime les répertoires/clés reg ?", vbQuestion Or vbYesNo, "Question!")
If reslt = vbNo Then End
mahelan
Messages postés51Date d'inscriptionmercredi 21 février 2007StatutMembreDernière intervention 4 avril 2007 24 févr. 2007 à 21:21
Salut,
j'ai une erreur la?
Dim reslt 'As VbMsgBoxResult
reslt = MsgBox("Voulez-vous que ce script supprime les répertoires/clés reg ?", vbQuestion Or vbYesNo, "Question!")
If reslt = vbNo Then End
Dim objFSO ' As Object
Dim WshShell ' As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("Wscript.Shell")
objFSO.DeleteFile ("C:\WINDOWS\Tasks\AA8E950191850569.job")
objFSO.DeleteFolder ("C:\Documents and Settings\All Users\Application Data\Dent Exit Log Fast")
objFSO.DeleteFolder ("C:\Documents and Settings\Thibaud Caquant\Application Data\Once Dog Ace")
objFSO.DeleteFolder ("C:\Documents and Settings\Thibaud Caquant\Application Data\BitRoll")
objFSO.DeleteFolder ("C:\Program Files\BitRoll")
objFSO.DeleteFolder ("C:\Program Files\Once Dog Ace")
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\log fast hole gram"
WshShell.RegDelete "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ViewMode"
WshShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow\netsearchsoft.com"
WshShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\New Windows\Allow\www.netsearchsoft.com"
WshShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce\MonVBS", "C:\MonVBS.vbs"
Call WshShell.Exec("tsshutdn /REBOOT /DELAY:1")
Set objFSO = Nothing
Set WshShell = Nothing