找回密码
 加入
搜索
查看: 5028|回复: 6

[AU3基础] [已解决]麻烦各位老师帮忙看下几句cmd脚本命令如何写成AU3的格式?

  [复制链接]
发表于 2010-10-22 18:40:25 | 显示全部楼层 |阅读模式
本帖最后由 smooth 于 2010-11-9 08:31 编辑

我按照语法格式,将以下本来属于cmd命令的代码写成了AU3的格式,但是不知道为什么,运行之后没有效果,麻烦各位老师帮忙看下,谢谢。
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do del /s /q /f /a %%a:\history.dat", '', 0)
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do del /s /q /f /a %%a:\history.dat.bak", '', 0)
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do del /s /q /f /a %%a:\history6.dat", '', 0)
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do del /s /q /f /a %%a:\history6.dat.rescue", '',0)
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do del /s /q /f /a %%a:\ThunderStorage.dat", '', 0)
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do rmdir /s /q %%a:\recycler >nul 2>nul & mkdir %%a:\recycler >nul 2>nul & rd /s /q %%a:\recycler", '', 0)
RunWait(@ComSpec & " /c for %%a in (c d e f g h i j k) do del /s /q /f /a %%a:\playlist.smpl", '', 0)
RunWait(@ComSpec & ' /c for /f %%a in ('dir /ad /b "%systemroot%\$*$"') do rd /s /q "%systemroot%\%%a"', '', 0)
发表于 2010-10-22 18:57:06 | 显示全部楼层
用批处理执行时 是用2个%%  
现在你用AU3直接调用CMD的话,是用一个%的
你把 %%a  修改成  %a 试试看

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-10-22 20:35:20 | 显示全部楼层
本帖最后由 smooth 于 2010-10-22 20:40 编辑

回复 2# 都市浪子666
谢谢这老师的回答。
我根据您的指导,确实可以了。不过还有一行修改之后也不行,您能不能再帮忙看下?
RunWait(@ComSpec & ' /c for /f %a in ('dir /ad /b "%systemroot%\$*$"') do rd /s /q "%systemroot%\%a"', '', 0)
发表于 2010-10-23 01:15:29 | 显示全部楼层
本帖最后由 都市浪子666 于 2010-10-23 01:21 编辑
回复  都市浪子666
谢谢这老师的回答。
我根据您的指导,确实可以了。不过还有一行修改之后也不行,您能 ...
smooth 发表于 2010-10-22 20:35


要执行的CMD命令是      for /f "tokens=*" %a in ('dir /ad /b "%systemroot%\$*$"') do rd /s /q "%systemroot%\%a"

你可以先把runwait的第一个参数用MsgBox 显示出来,看显示的是不是跟 要执行的CMD命令是一样
MsgBox(0,0,@ComSpec & ' /c  for /f "tokens=*" %a in ('  & "'dir /ad /b  "  &  '"%systemroot%\$*$"' & "') do rd /s /q " & '"%systemroot%\%a"')

RunWait(@ComSpec & ' /c  for /f "tokens=*" %a in ('  & "'dir /ad /b  "  &  '"%systemroot%\$*$"' & "') do rd /s /q " & '"%systemroot%\%a"' , @TempDir ,@SW_HIDE)
PS :要执行这行CMD命令,里面有单引号和双引号,在写AU3代码时,要分成几个部分来写,
                如果是执行的CMD命令中有单引号时,在写AU3代码时,就用双引号来包括
                如果是执行的CMD命令中有双引号时,在写AU3代码时,就用单引号来包括  几个部分之间用 & 来连接

评分

参与人数 1金钱 +30 收起 理由
lixiaolong + 30 学习了

查看全部评分

 楼主| 发表于 2010-10-23 08:35:24 | 显示全部楼层
回复 4# 都市浪子666

回答非常细致,谢谢您的指导!
发表于 2010-10-23 18:45:58 | 显示全部楼层
学习了   
发表于 2014-3-8 10:34:37 | 显示全部楼层
http://www.autoitx.com/forum.php?mod=viewthread&tid=9838&highlight=cmd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 16:20 , Processed in 0.084393 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表