Apr
30
VB把程序加入系统启动项的方法
雪糕先生 2009/04/30
15:42
15:42
引用
sub RegRun()
on error resume next
dim wsh
set wsh=createobject("wscript.shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\" & app.exename,app.path & "\" & app.exename & ".exe",REG_SZ"
end sub
on error resume next
dim wsh
set wsh=createobject("wscript.shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\" & app.exename,app.path & "\" & app.exename & ".exe",REG_SZ"
end sub
只要执行regrun这个过程,就会把自己写入启动项
wsh.regwrite 三部分意义:
wsh.regwrite 写入的位置,写入的值,写入的类型
HKLM\Software\Microsoft\Windows\Currentversion\Run\
是启动项的位置也叫键名,值的名称任意,值的内容为要启动的程序的路径
比如你要把IE写入启动项,就这样写
引用
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\IE","C:\Program Files\Internet Explorer\IExplorer.exe","REG_SZ"
前面那段代码就是把程序自身写入启动项的,
引用
Private Sub Command1_Click() '//第一个按钮的代码
Dim Reg As Object
Set Reg = CreateObject("Wscript.Shell")
Reg.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\MYEXES", App.Path & IIf(Len(App.Path) = 3, "", "\") & App.EXEName & ".Exe", "REG_SZ"
Set Reg = Nothing
End Sub
Private Sub Command2_Click() '//第2个按钮的代码
Dim Reg As Object
Set Reg = CreateObject("Wscript.Shell")
Reg.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\MYEXES"
Set Reg = Nothing
End Sub
Dim Reg As Object
Set Reg = CreateObject("Wscript.Shell")
Reg.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\MYEXES", App.Path & IIf(Len(App.Path) = 3, "", "\") & App.EXEName & ".Exe", "REG_SZ"
Set Reg = Nothing
End Sub
Private Sub Command2_Click() '//第2个按钮的代码
Dim Reg As Object
Set Reg = CreateObject("Wscript.Shell")
Reg.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\MYEXES"
Set Reg = Nothing
End Sub
赞助商链接
分类
热门文章
- [21863]五种方法安装Windows...
- [5891]雪糕乐园小游戏集2.04版!...
- [5750]开机自动检测网络状态运行程序...
- [5424]双路由器上网的连接和设置方法
- [4732]Google提供的免费天气预...
- [4693]QQ临时会话(强制聊天)工具...
- [4623]EvaPhone - 无需注...
- [4608]ESET NOD32最新升级...
- [4487]WINDOWS 7 如何快速...
- [4038][原创]雪糕乐园-图片轮换屏...
VB访问SQL Server数据的常用方法
vb移动无边框窗体源码
