求 设置开机启动工具 源码
本帖最后由 cjhhuanshao 于 2010-7-30 19:25 编辑论坛的开机启动设置工具功能太多了,我想要 设置 开/关机 两个小功能 就行了。 指定一个程序 不用自己动手添加上去。在这里先谢谢了! #include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("xx", 250, 240, -1, -1)
FileInstall("top.bmp", @TempDir & "\top.bmp")
$Pic1 = GUICtrlCreatePic(@TempDir & "\top.bmp", 0, 0, 249, 73)
FileDelete(@TempDir & "\top.bmp")
$Group1 = GUICtrlCreateGroup("xx 设置", 0, 80, 250, 81)
$Button1 = GUICtrlCreateButton("开机启动", 16, 100, 99, 49)
$Button2 = GUICtrlCreateButton("取消开机启动", 144, 100, 91, 49)
$Label1 = GUICtrlCreateLabel("今天您xx?", 16, 176)
$Label2 = GUICtrlCreateLabel("请支持xx www.xxx.cn", 16, 200)
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
FileCreateShortcut(@ScriptDir & "\xx.exe", @StartupDir & "\xx.lnk")
MsgBox(0, "", "ok")
Case $Button2
If FileExists(@StartupDir & "\xx.lnk") Then FileDelete(@StartupDir & "\xx.lnk")
MsgBox(0, "", "ok")
Case $Label2
Run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE www.xxx.cn")
EndSwitch
WEnd 本帖最后由 cjhhuanshao 于 2010-7-29 10:57 编辑
回复 2# lindafu
谢谢了楼上的兄弟。辛苦你了! ;我也来凑凑热闹
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("开机启动设置工具", 600, 100, -1, -1)
$Input1 = GUICtrlCreateInput("C:\WINDOWS\system32\cmd.exe /k ipconfig /all", 24, 24, 509, 21)
$Button1 = GUICtrlCreateButton("浏览", 540, 24, 50, 21)
$Button2 = GUICtrlCreateButton("设置启动运行", 100, 60, 100, 25)
$Button3 = GUICtrlCreateButton("取消启动运行", 250, 60, 100, 25)
$Button4 = GUICtrlCreateButton("退出", 400, 60, 60, 25)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button4
exit
case $Button1
$var = FileOpenDialog("选择启动运行的程序", "", "可执行文件(*.exe;*.cmd;*.bat;*.vbs)")
If @error Then
Else
GUICtrlSetData($Input1,$var)
EndIf
case $Button2
$run1 = GUICtrlRead($Input1)
$run2 = StringTrimLeft($run1,StringInStr($run1, "\",0,-1))
$run3 = StringLeft($run2,StringInStr($run2, ".",0,-1)-1)
if RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",$run3) = $run1 then
msgbox(48,"错误","此启动项已经存在,请勿重复设置!",3)
else
RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",$run3, "REG_SZ", $run1)
if RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",$run3) <> $run1 then msgbox(16,"失败","添加启动项失败!请检查用户和注册表权限!",3)
endif
case $Button3
$run1 = GUICtrlRead($Input1)
$run2 = StringTrimLeft($run1,StringInStr($run1, "\",0,-1))
$run3 = StringLeft($run2,StringInStr($run2, ".",0,-1)-1)
if RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",$run3) = $run1 then
RegDelete("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",$run3)
if RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run",$run3) = $run1 then msgbox(16,"失败","删除启动项失败!请检查用户和注册表权限!",3)
else
msgbox(48,"错误","此启动项不存在!")
endif
EndSwitch
WEnd
回复 4# xsjtxy
2楼就是我想要的结果。。谢谢你了!你也辛苦了! 回复 2# lindafu
兄弟 再麻烦你一下 刚才测试一下 设置 启动 查看 起始位置空白的...设置了开机启动。开机出错问题的.
FileCreateShortcut(@ScriptDir & "\xx.exe", @StartupDir & "\xx.lnk", @ScriptDir) 回复 7# lindafu
谢谢了 哈!! 啊 学习了哈哈 真搞不懂这个东西的意义在哪 学习。。。。。。。。。。。。 谢谢2楼!~~~~ 回复 4# xsjtxy
学习了,看上去还不错!
页:
[1]