用VB做一个清理启动项的按钮
用VB建一个按钮,点击后执行以下注册表修改:1.删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersi...
用VB 建一个按钮,点击后执行以下注册表修改:1.删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"的默认值。2.删除"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"的默认值。3.删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"里的项。4.删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"里的项。5.在"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"里新建个ctfmon.exe,数值为%systemroot%\system32\ctfmon.exe 。
也就是说写一个清理启动项的按钮。验证成功后再高分追加。
要求是删除指定目录下所有的项,有可能是一项或多项,并且名子未知。如果指定是CTFMON这一项很容易写的,继续努力,帮忙搞定,高分追加
辛苦辛苦,虽然我已搞定,分还是属于你,谢谢! 展开
也就是说写一个清理启动项的按钮。验证成功后再高分追加。
要求是删除指定目录下所有的项,有可能是一项或多项,并且名子未知。如果指定是CTFMON这一项很容易写的,继续努力,帮忙搞定,高分追加
辛苦辛苦,虽然我已搞定,分还是属于你,谢谢! 展开
2个回答
展开全部
一、建立一个模块:
Option Explicit
Global Const REG_SZ As Long = 1
Global Const REG_DWORD As Long = 4
Global Const REG_BINARY As Long = 3
Global Const HKEY_CLASSES_ROOT = &H80000000
Global Const HKEY_CURRENT_USER = &H80000001
Global Const HKEY_LOCAL_MACHINE = &H80000002
Global Const KEY_ALL_ACCESS = &H3F
Global Const REG_OPTION_NON_VOLATILE = 0
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private lNewKey As Long
Public Function CreateNewKey(lPredefinedKey As Long, sNewKeyName As String)
Dim hNewKey As Long
Dim lRetVal As Long
lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
RegCloseKey (hNewKey)
End Function
Public Function DeleteKey(lPredefinedKey As Long, sKeyName As String)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegDeleteKey(lPredefinedKey, sKeyName)
RegCloseKey (hKey)
End Function
Public Function DeleteValue(lPredefinedKey As Long, sKeyName As String, sValueName As String)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegDeleteValue(hKey, sValueName)
RegCloseKey (hKey)
End Function
Public Function SetStringValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, vValueSetting As String)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegSetValueExString(hKey, sValueName, 0&, REG_SZ, vValueSetting, LenB(StrConv(vValueSetting, vbFromUnicode)))
RegCloseKey (hKey)
End Function
二、函数调用:
Private Sub Command1_Click()
'删除默认值
DeleteValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", "" '删除默认值
DeleteValue HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", "" '删除默认值
'删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"里的项
DeleteKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"
'删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"里的项
DeleteKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
'在"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"里新建个ctfmon.exe,数值为%systemroot%\system32\ctfmon.exe
SetStringValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", "ctfmon.exe", "%systemroot%\system32\ctfmon.exe"
End Sub
Option Explicit
Global Const REG_SZ As Long = 1
Global Const REG_DWORD As Long = 4
Global Const REG_BINARY As Long = 3
Global Const HKEY_CLASSES_ROOT = &H80000000
Global Const HKEY_CURRENT_USER = &H80000001
Global Const HKEY_LOCAL_MACHINE = &H80000002
Global Const KEY_ALL_ACCESS = &H3F
Global Const REG_OPTION_NON_VOLATILE = 0
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private lNewKey As Long
Public Function CreateNewKey(lPredefinedKey As Long, sNewKeyName As String)
Dim hNewKey As Long
Dim lRetVal As Long
lRetVal = RegCreateKeyEx(lPredefinedKey, sNewKeyName, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hNewKey, lRetVal)
RegCloseKey (hNewKey)
End Function
Public Function DeleteKey(lPredefinedKey As Long, sKeyName As String)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegDeleteKey(lPredefinedKey, sKeyName)
RegCloseKey (hKey)
End Function
Public Function DeleteValue(lPredefinedKey As Long, sKeyName As String, sValueName As String)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegDeleteValue(hKey, sValueName)
RegCloseKey (hKey)
End Function
Public Function SetStringValue(lPredefinedKey As Long, sKeyName As String, sValueName As String, vValueSetting As String)
Dim lRetVal As Long
Dim hKey As Long
lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegSetValueExString(hKey, sValueName, 0&, REG_SZ, vValueSetting, LenB(StrConv(vValueSetting, vbFromUnicode)))
RegCloseKey (hKey)
End Function
二、函数调用:
Private Sub Command1_Click()
'删除默认值
DeleteValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", "" '删除默认值
DeleteValue HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", "" '删除默认值
'删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"里的项
DeleteKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg"
'删除"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"里的项
DeleteKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
CreateNewKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Shared Tools\MSConfig\startupfolder"
'在"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"里新建个ctfmon.exe,数值为%systemroot%\system32\ctfmon.exe
SetStringValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", "ctfmon.exe", "%systemroot%\system32\ctfmon.exe"
End Sub
展开全部
Dim rrr
Set rrr=WScript. _
CreateObject("WScript.Shell")
rrr.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ctfmon.exe"
rrr.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\ctfmon.exe"
rrr.regdelete "HKLM\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\ctfmon.exe"
rrr.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\ctfmon.exe"
'补充:
rrr.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\"
'要删除整个项,则省略键值名,后面加\
'提示删除整个运行项会使软件不能自动运行,包括杀毒软件
Set rrr=WScript. _
CreateObject("WScript.Shell")
rrr.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ctfmon.exe"
rrr.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\ctfmon.exe"
rrr.regdelete "HKLM\SOFTWARE\Microsoft\Shared Tools\MSConfig\startupreg\ctfmon.exe"
rrr.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\ctfmon.exe"
'补充:
rrr.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\"
'要删除整个项,则省略键值名,后面加\
'提示删除整个运行项会使软件不能自动运行,包括杀毒软件
参考资料: http://zhidao.baidu.com/question/83366126.html?si=2
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询