html tool

显示标签为“cmd”的博文。显示所有博文
显示标签为“cmd”的博文。显示所有博文

2022年8月4日星期四

cmd while ture

参考:https://www.yiibai.com/batch_script/batch_script_while_statement_implementation.html :while ping www.baidu.com timeout /T 1 goto :while

2021年12月22日星期三

转:cmd远程删除文件夹

 参考:https://cloud.tencent.com/developer/article/1487725

解决方式:

使用方法:

net use \\192.168.17.138\c$ "admin123" /user:pt007
net use
rmdir /s/q \\192.168.17.138\c$\q.txt

转:cmd删除文件夹

 参考:https://blog.csdn.net/centralperk/article/details/8603514

rmdir 删除整个目录 好比说我要删除 222 这个目录下的所有目录和档案,这语法就是: rmdir /s/q 222 其中: /s 是代表删除所有子目录跟其中的档案。 /q 是不要它在删除档案或目录时,不再问我 Yes or No 的动作。 要删除的目录前也可以指定路径,如: rmdir /s/q d:\123\abc 这意思是告诉计算机,把磁盘驱动器 D 的123资料夹里面的abc资料夹中的所有东西全部删除,同时也不要再问我是否要删除。

2021年11月4日星期四

cmd递归显示指定目录及其子目录中的全部文件

参考:https://blog.csdn.net/angelazy/article/details/44174663 


/S 显示指定目录和所有子目录中的文件

 可以在 DIRCMD 环境变量中预先设定开关。通过添加前缀 - (破折号)
  来替代预先设定的开关。例如,/-W。
  dir x: /a:d 只显示X盘下所有的目录
  dir x: /a:-d 只显示X盘下所有的文件


测试效果:

显示c:\windows 及其子目录下的全部文件

dir c:\windows /S /a:-d  


2021年10月12日星期二

转:mshta运行vbs,js代码 (在cmd中)

 https://m.yisu.com/zixun/404267.html

https://www.cnblogs.com/liaomin416100569/p/9331261.html


mshta vbscript:Close(Execute("GetObject(""script:https://xxx")

JS: 

复制代码代码如下:

mshta vbscript:window.execScript("alert('hello world!');","javascript") 



VBS: 

复制代码代码如下:

mshta javascript:window.execScript("msgBox('hello world!'):window.close","vbs") 

cmd添加文件为隐藏文件属性

 参考:

https://www.cnblogs.com/wangchaoguo-li/p/5987906.html

https://baike.baidu.com/item/%E9%9A%90%E8%97%8F/2813896

给文件添加隐藏属性

attrib +h

直接结果为dir中无法查看

2021年9月26日星期日

转:cmd的wc -l

https://blog.csdn.net/bendanban/article/de

将之前命令的输出结果定向给 FIND /v "" /c (它的意思是看下所有不包含字符串""的行),

也就是说,计算所有行!

通过使用/v “” ,我们会查询到所有非空行,这在输出的所有字符串非常不同的情况下很有用。

要是你用过Unix上的wc,那么上面的命令就相当于 wc -l_



2021年5月27日星期四

转:CMD获取当前目录的绝对路径

 https://blog.csdn.net/Sagittarius_Warrior/article/details/51516195

  1. @echo off
  2. echo 当前盘符:%~d0
  3. echo 当前盘符和路径:%~dp0
  4. echo 当前批处理全路径:%~f0
  5. echo 当前盘符和路径的短文件名格式:%~sdp0
  6. echo 当前CMD默认目录:%cd%
  7. echo 目录中有空格也可以加入""避免找不到路径
  8. echo 当前盘符:"%~d0"
  9. echo 当前盘符和路径:"%~dp0"
  10. echo 当前批处理全路径:"%~f0"
  11. echo 当前盘符和路径的短文件名格式:"%~sdp0"
  12. echo 当前CMD默认目录:"%cd%"

2021年2月24日星期三

转:cmd中的cat-type

 https://superuser.com/questions/434870/what-is-the-windows-equivalent-of-the-unix-command-cat




type

It works across command.comcmd, and PowerShell (though in the latter it's an alias for Get-Content, so is cat, so you could use either). From the Wikipedia article (emphasis mine):

In computing, type is a command in various VMS. AmigaDOS, CP/M, DOS, OS/2 and Microsoft Windows command line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS/4NT and Windows PowerShell. It is used to display the contents of specified files. It is analogous to the Unix cat command.

C:\>echo hi > a.txt
C:\>echo bye > b.txt
C:\>type a.txt b.txt > c.txt
C:\>type c.txt
hi
bye

2018年12月17日星期一

AHK cmd run


https://wapiknow.baidu.com/question/547051459.html?entrytime=1545104073339

SetTitleMatchMode 2
dir=c:\WINDOWS
run,cmd
WinWait, ahk_class ConsoleWindowClass,
IfWinNotActive, ahk_class ConsoleWindowClass, , WinActivate, ahk_class ConsoleWindowClass,
WinWaitActive, ahk_class ConsoleWindowClass,
ControlSend, , cd /d %dir% {Enter}, cmd.exe ; 直接发送到命令提示符窗口.要配合SetTitleMatchMode RegEx或SetTitleMatchMode 2

2018年9月26日星期三

bat 无限循环goto


https://blog.csdn.net/u010913204/article/details/52701291

一个简单易行的方式:
:loop 
goto loop

2018年9月25日星期二

转:Browse an UNC path using Windows CMD without mapping it to a network drive



https://superuser.com/questions/282963/browse-an-unc-path-using-windows-cmd-without-mapping-it-to-a-network-drive

问题:
C:\> cd \\somewhere
'\\somewhere'
CMD does not support UNC paths as current directories.

处理方式:
增加nass为本地磁盘处理的
net use x: \\computer name\share name

[popexizhi:
当前的问题,原文推荐的,自己的有nass有user和password , 没有测试通过,这个pushd的使用待进一步研究
pushd  will create a temporary virtual drive and get into it.
popd will delete the temporary drive and get you back to the path you were when you entered pushd.
Example:
C:\a\local\path> pushd \\network_host\a\network\path

U:\a\network\path> REM a temporary U: virtual drive has been created

U:\a\network\path> popd

C:\a\local\path> REM the U: drive has been deleted

C:\a\local\path>
]


2017年12月19日星期二

cmd中运行powershell脚本


powershell -ExecutionPolicy ByPass -File ./changDemo.ps1p
#cmd run powershell

2017年12月18日星期一

windows start bat

需求描述:
使用start wait 等待 setupFactory build over

方式:


start ""/wait "G:\Program Files (x86)\Setup Factory 9\SUFDesign.exe" /BUILD "$path\NexusWindows.suf" "/STDOUT" "" 
dir H:\pc\work\git_33\output
pause
【popexizhi: 注意start 之后的 “” 和执行结束 也使用“”
[?] powershell如何调用没测试

2017年10月17日星期二

Setup Factory build in cmd


[popexizhi:
刚刚发现 Setup Factory 可以在命令行build ,官方帮助如下,bela.
]

Command Line Options

/BUILD

Tells Setup Factory to build the project file passed in on the cmd line or from a batch file. For example:
"C:\Program Files\Setup Factory 9\SUFDesign.exe" /BUILD "C:\TestProj.suf"


Tip: If you are running the build from a batch file, you can use "start /wait", for example:
start "" /wait "C:\Program Files\Setup Factory 9\SUFDesign.exe" /BUILD ...



/STDOUT

Makes the build status go to the standard output device.
For example, if Setup Factory's build is run from another product that captures the standard output:
"C:\Program Files\Setup Factory 9\SUFDesign.exe" /BUILD "C:\TestProj.suf" "/STDOUT"

Or, if you want to pipe the output to a new file:
"C:\Program Files\Setup Factory 9\SUFDesign.exe" /BUILD "C:\TestProj.suf" "/STDOUT" > "C:\build_output.txt"
[popexizhi: 这个 /STDOUT 很奇怪,自己的测试没有作用,why? ]