Apr
30
VB把程序加入系统启动项的方法
雪糕先生 2009/04/30 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
分类
热门文章
- [46488]五种方法安装Windows...
- [31118]您可能需要与该网络的 in...
- [15800]2012东埔英歌舞
- [15076]开机自动检测网络状态运行程...
- [14528]APMServ一键快速搭建...
- [13753]各种BIOS的设置细解
- [13519]EvaPhone - 无需...
- [13419]Google提供的免费天气...
- [13118]双路由器上网的连接和设置方...
- [12618]雪糕乐园小游戏集2.04版...