win7当前目录创建快捷方式-创新互联

注:bat脚本使用ANSI编码

成都创新互联公司提供高防主机、云服务器、香港服务器、绵阳服务器托管
  1. 第一种

@ echo off

cd /d %~dp0

set onepath=%cd%

echo -----------------create file and cat----------------------------

for /l %%i in (1 1 10) do echo "this is test for test-%%i" >>testfile.txt

type testfile.txt

tree

echo -----------------create file link----------------------------------

set sourcefile=%onepath%\testfile.txt

echo [InternetShortcut] >>testfile.url

echo URL="%sourcefile%" >>testfile.url

echo IconIndex=0 >> testfile.url

echo IconFile="%onepath%\testfile.txt%" >>testfile.url

echo %errorlevel%

pause

2.第二种

@ echo off

color 0a

set onepath=%cd%

echo -----------------create file and cat----------------------------

for /l %%i in (1 1 10) do echo "this is test for test-%%i" >>testfile.txt

type testfile.txt

tree

echo -----------------create file link----------------------------------

::设置程序或文件的完整路径(必选)

set sourcefile=%onepath%\testfile.txt

::设置快捷方式名称(必选)

set LnkName=testfile

::设置程序的工作路径,一般为程序主目录,此项若留空,脚本将自行分析路径

::set WorkDir=

::设置快捷方式显示的说明(可选)

set Desc=测试

(echo Set WshShell=CreateObject("WScript.Shell"^)

echo strDesKtop=WshShell.SpecialFolders("%onepath%"^)

echo Set oShellLink=WshShell.CreateShortcut("%onepath%" ^&"\%LnkName%.lnk"^)

echo oShellLink.TargetPath="%sourcefile%"

echo oShellLink.WorkingDirectory="%onepath%"

echo oShellLink.WindowStyle=1

echo oShellLink.Description="%Desc%"

echo oShellLink.Save)>makelnk.vbs

makelnk.vbs

del /f /q makelnk.vbs

::exit

if %errorlevel%==0 (

  echo create file link success!

)

echo ---------------------------------------create dir link-------------------------------

tree %onepath%

pause

3. 举例文件与文件夹均创建快捷方式

@ echo off

title bat to dir or file test

color 0a

cd /d %~dp0

set onepath=%cd%

echo -----------------------date:%date%-----------------------------

echo %date% >> testfile.txt

echo -----------------------time:%time%-----------------------------

echo %time% >> testfile.txt

echo -----------------create file and cat----------------------------

for /l %%i in (1 1 10) do echo "this is test for test-%%i" >>testfile.txt

type testfile.txt

echo -----------------create dir testdir----------------------------------

md testdir

tree

echo ------------------move testfile to testdir--------------------------

move testfile.txt %onepath%\testdir

echo ------------------rename testdir testdir1------------------------

move testdir testdir1

echo -------------------cd testdir1----------------------------------

cd %onepath%\testdir1

echo ------------------rename testfile.txt testfile1.txt------------------

move testfile.txt testfile1.txt

echo -------------------copy testfile1.txt testfile1.bak------------------

copy testfile1.txt testfile.bak

echo --------------------move testdir1/testfile1.txt to %onepath%--------

move testfile1.txt %onepath%

echo ------------------cd %onepath%-----------------------------

cd %onepath%

echo ------------------list %onepath%---------------------------

tree %onepath%

echo -------------------create link--------------------------------------

::set var delay

setlocal EnableDelayedExpansion

for %%a in (testfile1.txt testdir1) do (

  echo "star create link"

(echo Set WshShell=CreateObject("WScript.Shell"^)

  echo strDesKtop=WshShell.SpecialFolders("%onepath%"^)

  echo Set oShellLink=WshShell.CreateShortcut("%onepath%" ^&"\%%a-test.lnk"^)

  echo oShellLink.TargetPath="%onepath%\%%a"

  echo oShellLink.WorkingDirectory="%onepath%"

  echo oShellLink.WindowStyle=1

echo oShellLink.Save)>makelnk.vbs

  makelnk.vbs

if %errorlevel%==0 (

    echo "create  %%a link success!"

  )

::type makelnk.vbs

del /f /q makelnk.vbs

)

if %errorlevel%==0 (

  echo "create  all link success!"

)

echo -------------list %onepath% structure---------

tree %onepath%

echo -------------dir %onepath%---------

dir %onepath%

pause

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

文章名称:win7当前目录创建快捷方式-创新互联
文章出自:https://www.cdcxhl.com/article48/dpeshp.html

成都网站建设公司_创新互联,为您提供定制网站域名注册响应式网站网站维护营销型网站建设电子商务

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

小程序开发