找回密码
 加入
搜索
查看: 5044|回复: 5

[系统综合] 非数组变量使用下标 错误在哪?

[复制链接]
发表于 2012-5-13 16:40:38 | 显示全部楼层 |阅读模式
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Outfile=111111111.exe
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****

$hSearch = FileFindFirstFile(@DesktopDir & "\*.lnk")

While 1
    $sFile = FileFindNextFile($hSearch)
    $FilePath = FileGetShortcut(@DesktopDir & '\' & $sFile)

If $FilePath[0] = 'C:\1.exe' Then
        IF Not StringInStr(FileGetAttrib(@DesktopDir & '\' & $sFile), 'H') Then
                FileSetAttrib(@DesktopDir & '\' & $sFile, '+H')
                                
        EndIf
        EndIf
        
sleep(100)
Wend






出错。。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2012-5-13 17:49:33 | 显示全部楼层
有一个程序一运行 就会不断的在桌面建立随机名快捷方式!
发表于 2012-5-13 19:12:53 | 显示全部楼层
$hSearch = FileFindFirstFile(@DesktopDir & "\*.lnk")
While 1
    $sFile = FileFindNextFile($hSearch)
        If @error Then ExitLoop;;;;;;;
    $FilePath = FileGetShortcut(@DesktopDir & '\' & $sFile)
        If Not StringCompare($FilePath[0], "C:\Program Files\Tencent\QQ2011beta\Bin\QQ.exe") Then
        IF Not StringInStr(FileGetAttrib(@DesktopDir & '\' & $sFile), "H") Then
                        FileSetAttrib(@DesktopDir & '\' & $sFile, "+H")
                EndIf
        EndIf
        sleep(100)
Wend
发表于 2012-5-13 19:20:25 | 显示全部楼层
$hSearch = FileFindFirstFile(@DesktopDir & "\*.lnk")
While 1
    $sFile = FileFindNextFile($hSearch)
        If @error Then ExitLoop;;;;;;;
    $FilePath = FileGetShortcut(@DesktopDir & '\' & $sFile)
        ;If Not StringCompare($FilePath[0], "C:\Program Files\Tencent\QQ2011beta\Bin\QQ.exe") Then
        If $FilePath[0] = "C:\Program Files\Tencent\QQ2011beta\Bin\QQ.exe" Then
        IF Not StringInStr(FileGetAttrib(@DesktopDir & '\' & $sFile), "H") Then
                        FileSetAttrib(@DesktopDir & '\' & $sFile, "+H")
                EndIf
        EndIf
        sleep(100)
Wend

;;;  $FilePath[0] = "C:\Program Files\Tencent\QQ2011beta\Bin\QQ.exe"
;;;  这样也是可以的
;;;  问题应该是由于 FileFindNextFile出错时 $sFile 不是文件名 而是空字符串
;;;  进一步导致FileGetShortcut出错,返回值 不是数组
发表于 2012-5-13 20:45:53 | 显示全部楼层
由于某种未知原因,$FilePath 不是数组
发表于 2012-5-14 03:08:22 | 显示全部楼层
lz先查查桌面目录里有没有lnk文件吧,看看是@DesktopDir还是@DesktopCommonDir
或者在中间加一句if isarray($filepath) then msgbox来确定下数组到底返回的对不对,在考虑后续步骤
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-20 13:55 , Processed in 0.077518 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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