winxp的自动加载(VBSCRIPT实现)

第一种:在开始菜单的启动里加载;
' Date:2007-07-27 By:Snowhill
set args=WScript.Arguments
if args.Count=0 then
 MsgBox "Please drag vbs script file on my icon" & "I'm place int into the Startup group"
 WScript.Quit
 end if
 
 set fs=CreateObject("Scripting.FileSystemObject")
 set wshshell=CreateObject("WScript.Shell")
 scriptfile=args(0)
 '获取扩展文件名
 if not lcase(fs.GetExtensionName(scriptfile))="vbs"then 
 MsgBox "I only accept vbs script files!"
 WScript.Quit
 end if
 
startup =wshshell.SpecialFolders("Startup")
name=InputBox("Under which name should I place the scripte" & """"_
         & fs.GetBaseName(scriptfile)&"""into the startup"_
         &"group?","autostrat script")
         
set scut=wshshell.CreateShortcut(startup&"\"&name&".lnk")
         scut.TargetPath=scriptfile
         scut.Save
MsgBox "Script has been successfully linked to your startup group!"
 
第二种:在注册表里添加;
'date:2007-07-27 by:snowhill
set args=WScript.Arguments
if args.Count=0 then
    MsgBox "Please drag a vbs script file on my icon"_
    & "I'm place it into the startup group!"
    WScript.Quit
end if

set fs=CreateObject("Scripting.FileSystemObject")
set wshshell=CreateObject("WScript.Shell")

scriptfile=args(0)
if not lcase(fs.GetExtensionName(scriptfile))="vbs" then
    MsgBox "I only accept vbs script files!"
    WScript.Quit
end if

key="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\"
' use this key on windows NT/2K
'key="HKLM\Software\microsoft\windows NT\CurrentVersion\Run\"
'写入当前用户的注册表值
'key="HKU\Software\microsoft\windows\CurrentVersion\Run\"
wshshell.RegWrite key&"myscript",scriptfile
MsgBox "Script has been success fully added to the Run key!"

注:在HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\下的userinit好像也可以加载;
     在HKCU\software\microsoft\windows nt\CurrentVersion\windows\下的Load也可以载;
第三种:在组策略里设置:
   本地计算机策略->WINDOWS设置->脚本(启动/关机),这个具体是怎么实现的是个?反正可以加载,至于怎么用用命令行或程序实现就是个??实际上他是改动了以下文件:
C:\WINDOWS\System32\GroupPolicy\Machine\Scripts这里面有一个scripts.ini文件,其编写格式如下:
0CmdLine=D:\run.vbs
0Parameters=
1CmdLine=D:\run1.vbs
1Parameters=
2CmdLine=D:\run2.vbs
2Parameters=
直接改就可以实现了.
   另外像改AUTOEXEC.BAT这种就不提了.

posted on 2007-07-27 10:02 snowhill 阅读(501) 评论(0)  编辑 收藏 引用 所属分类: 系统管理


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

导航

公告

又一年...........

留言簿(3)

随笔分类(13)

文章分类(131)

文章档案(124)

c++

java

linux

oracle

常用软件

其他

网络配置

系统安全

音乐

搜索

最新评论

阅读排行榜