随笔分类 -  dos

摘要:bat cmd 遍历符号链接,symlink 参考链接:batch file (windows cmd.exe) test if a file is a link - Stack Overflow @echo off set SearchTarget=%~dp0 for /f "tokens=*" 阅读全文
posted @ 2022-04-15 16:53 ibingshan 阅读(233) 评论(0) 推荐(0)
摘要:bat 判断字符串变量是否为空 set val=ddd if "%val%" == "" ( echo 字符串为空 ) pause 阅读全文
posted @ 2021-04-14 11:31 ibingshan 阅读(9849) 评论(2) 推荐(2)
摘要:bat 判断 bat 是否是以管理员权限运行,和自动以管理员权限运行 判断 @echo off net.exe session 1>NUL 2>NUL && ( goto as_admin ) || ( goto not_admin ) :as_admin echo as_admin goto en 阅读全文
posted @ 2019-08-08 18:42 ibingshan 阅读(4551) 评论(0) 推荐(1)
摘要:python cmd 窗口 中文乱码 解决方法 (附:打印不同颜色) 前言 在 python 开发中,有时候想通过cmd窗口来和用户交互,比如显示信息之类的,会比自己创建 GUI 来的方便,但是随之而来的就是编码乱码问题 下面例子在 python2 和 python3 中都可以运行,也可以在其它 . 阅读全文
posted @ 2019-07-19 16:41 ibingshan 阅读(3268) 评论(0) 推荐(0)
摘要:bat %n 判断传入的参数值和使用注意 if "%1" == "" echo empty 1 if exist "%1" echo 1path exist 注意:要加上双引号"",不然如果传入的参数是空的话,会导致bat闪退,因为如果是空,而没有双引号,那么就变成 if == "" echo em 阅读全文
posted @ 2019-07-09 10:55 ibingshan 阅读(4445) 评论(0) 推荐(0)
摘要:bat 读取 ini 文件 参考链接:https://stackoverflow.com/questions/2866117/windows-batch-script-to-read-an-ini-file 这个 bat 支持 ini 的键值与=号之间存在空格,例如 key1 = value1 re 阅读全文
posted @ 2019-06-28 13:38 ibingshan 阅读(3879) 评论(0) 推荐(0)
摘要:bat 提示窗口 各种窗口样式 这里只是一些提示窗口的样式,至于提示窗口的不同选择不同执行需要另外查看帮助 换行例子: 注意:vbscript:后面语法之间不要加任何空格,不然会报错 阅读全文
posted @ 2019-06-26 17:57 ibingshan 阅读(2554) 评论(0) 推荐(0)
摘要:bat wmic python 获取进程的所在路径 doc: python: 参考链接:https://superuser.com/questions/1003921/how-to-show-full-command-line-of-all-processes-in-windows 获取其它属性: 阅读全文
posted @ 2019-06-13 15:35 ibingshan 阅读(1950) 评论(0) 推荐(0)
摘要:bat 获取当前文件夹的文件名 阅读全文
posted @ 2019-05-22 17:37 ibingshan 阅读(6680) 评论(0) 推荐(0)
摘要:bat 获取当前目录的父目录 @echo off echo batchfile=%0 echo full=%~f0 setlocal for %%d in (%~dp0.) do set Directory=%%~fd echo Directory=%Directory% for %%d in (% 阅读全文
posted @ 2019-05-22 17:22 ibingshan 阅读(4985) 评论(0) 推荐(0)
摘要:bat echo 每行不同的颜色 先看代码: 使用注意事项: 1.你的代码放在 :start 和第一行 goto :eof之间 2.换行使用 echo. 3.最好使用双引号把内容括起来,不然遇到空格就会报拒绝访问的错误,内容如果包含特殊字符(例如:"a:!aa" 等等,一般是win不允许我们用来命名 阅读全文
posted @ 2019-05-22 16:19 ibingshan 阅读(5449) 评论(0) 推荐(0)
摘要:bat 判断命令是否执行成功 连接符形式,&& 表示成功,|| 表示失败,例如: call xxx.bat && (goto succeed) || goto failed :succeed echo successfully :failed echo failed pause 使用%errorle 阅读全文
posted @ 2019-05-22 15:24 ibingshan 阅读(8421) 评论(0) 推荐(0)
摘要:bat 判断变量字符串中是否包含字符串 代码注释: 在 way 1 中,加了 >nul 就可以不打印 echo 的内容, way1 可以不设置 setlocal 阅读全文
posted @ 2019-05-15 10:23 ibingshan 阅读(19745) 评论(2) 推荐(0)
摘要:bat 读取 ini 配置文件 config.ini: .bat: 注意:.bat 和 config.ini 在同一个文件夹 参考链接:https://www.cnblogs.com/urwlcm/p/4433871.html 阅读全文
posted @ 2019-05-15 09:32 ibingshan 阅读(5242) 评论(1) 推荐(0)
摘要:bat choice 命令 choice /c YNC /m "Are you sure?" if %errorlevel%==1 goto Y if %errorlevel%==2 goto N if %errorlevel%==3 goto C :Y echo Y :N echo N :C ec 阅读全文
posted @ 2019-04-12 14:16 ibingshan 阅读(1127) 评论(0) 推荐(0)