ppp092 发表于 2013-8-20 09:55:14

关于Run和ShellExecute这两个函数会不支持UNC怎么破啊?

Microsoft Windows
Copyright (c) 2009 Microsoft Corporation.All rights reserved.

C:\Users\Jack>"W:\Game_Install_all\Battlefield bad company\Setup.exe"

C:\Users\Jack>"\\192.168.8.198\autoserv\Game_Install_all\Battlefield bad company
\Setup.exe"

C:\Users\Jack>"W:\Game_Install_all\Battlefield bad company\Setup.exe"

C:\Users\Jack>"\\192.168.8.198\autoserv\Game_Install_all\Battlefield bad company
\Setup.exe"

C:\Users\Jack>"W:\Game_Install_all\Battlefield bad company\Setup.exe"

C:\Users\Jack>cd "\\192.168.8.198\autoserv\Game_Install_all\Battlefield bad comp
any"
'\\192.168.8.198\autoserv\Game_Install_all\Battlefield bad company'
CMD does not support UNC paths as current directories.


我用Run和ShellExecute函数对Setup.exerun不起来耶,有没有大神可以帮忙一下啊

代码:

ConsoleWrite(_Battlefield_Installation("\\192.168.8.198\autoserv\Game_Install_all\Battlefield bad company\Setup.exe","\\192.168.8.198\autoserv\Game_Install_all\Battlefield Bad Company_DVD\BFBC2Game.exe"))
Func _Battlefield_Installation($Dir,$patch)
        Sleep(2000)
        If RegRead("HKLM64\SOFTWARE\Wow6432Node\Electronic Arts\Battlefield Bad Company 2","Install Dir") Or RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Electronic Arts\Battlefield Bad Company 2","Install Dir") Then
                Return 1
        EndIf
        ConsoleWrite($Dir&@CRLF&StringTrimRight($Dir,9))
        If ShellExecute($Dir,StringTrimRight($Dir,9)) == 0 Then
               
                return 0
        EndIf
EndFunc



我在Cmd模式下用C:\Users\Jack>"W:\Game_Install_all\Battlefield bad company\Setup.exe" 又可以运行对应的exe文件。W是值得\\192.168.8.198\autoserv的map盘符。两种方式为什么执行结果不一样??求解~~

user3000 发表于 2013-8-20 18:37:48

回复 1# ppp092


不是Run 和 ShellExecute 的问题, 而是批处理本来不支持UNC
你先映射网络目录到本地再处理就行了.
AU3 有函数 DriveMapAdd

ppp092 发表于 2013-8-21 08:45:00

回复 2# user3000


    嗯,Thx。。。不谋而合,我正是用这种方法。在自己定义的UDF里面需要用是就Map一个盘并得到盘符。用完之后就删除掉。谢谢你~~user3000
页: [1]
查看完整版本: 关于Run和ShellExecute这两个函数会不支持UNC怎么破啊?