创建快捷方式,修改注册表

1.通过PowerShell创建快捷方式

$path = [Environment]::GetFolderPath("Desktop") + "\MyShortcut.lnk"
$comobject = New-Object -comObject WScript.Shell
$link = $comobject.CreateShortcut($path)
$link.targetpath = "notepad.exe"
$link.IconLocation = "notepad.exe,0"
$link.Save()

GetFolderPath()目录的类型可以在枚举值SpecialFolder中找到
[System.Environment+SpecialFolder] | Get-Member -static -memberType Property | select -ExpandProperty Name

 From:http://www.pstips.net/navigating-the-file-system.html

 

2.通过vbs创建快捷方式

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\ftp.lnk")
oShellLink.TargetPath = "ftp://192.168.12.22"
oShellLink.IconLocation = "%SystemRoot%\system32\url.dll, 0"
oShellLink.Description = "快捷方式"
oShellLink.Save

注:可以对地址创建,也可以对应用程序创建

===================================================

 

3.通过bat创建快捷方式

set path=%WINDIR%\notepad.exe
set topath="%USERPROFILE%\desktop\记事本.url"
echo [InternetShortcut] >> %topath%
echo URL="%path%" >> %topath%
echo IconIndex=0 >> %topath%
echo IconFile=%path% >> %topath%

 

set path=ftp://192.168.12.22
echo [[InternetShortcut] >>ftp.url 
echo URL="%path%" >>ftp.url 
::echo IconIndex=0 >>ftp.url
pause

注:双击脚本运行不成功,在cmd下直接运行命令可以成功

 

修改FTP默认打开方式:

1.打开注册表编辑器,定位到 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_INTERNET_SHELL_FOLDERS

2.双击右侧的“iexplorer.exe”,将数值数据由0改为1

 

script.vbs:(注:该脚本需要以管理员权限运行,否则会提示 非法的注册表根路径)

Dim Reg
Set Reg=WScript.CreateObject("WScript.Shell")
Path = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_INTERNET_SHELL_FOLDERS\"
Reg.RegWrite Path&"iexplore.exe","1","REG_DWORD"msgbox Reg.RegRead (Path&"iexplore.exe")

Reg.RegDelete

 

 

posted on 2013-10-28 16:42  momingliu11  阅读(1333)  评论(0编辑  收藏  举报