dim fso
Set M = CreateObject("Wscript.Shell")
set fso=createobject("scripting.filesystemobject")
if fso.FolderExists("1.exe") then
M.run "1.exe"
else
MsgBox("可执行文件不存在!")
end if说明:这段代码执行的结果是,无论1.exe是否存在,都提示不存在,麻烦各位看看!

解决方案 »

  1.   

    我这边也没vb环境,不过从注册表查看情况,createobject后面的参数指定的两个对象都存在,那么不妨从对象创建后方法上入手,你的"1.exe"是文件啊,应该用FileExists方法吧,不是FolderExists。试试吧,我不确定。
      

  2.   

    dim fso 
    Set M = CreateObject("Wscript.Shell") 
    set fso=createobject("scripting.filesystemobject") 
    if fso.FileExists("C:\WINDOWS\system32\calc.exe") then 
    M.run "C:\WINDOWS\system32\calc.exe" 
    else 
    MsgBox("可执行文件不存在!") 
    end if 我用这段代码,可以运行出计算器,你参考后看看吧,还需要路径。
      

  3.   


    你看下面这个方法错在哪里呢?dim fso
    Set M = CreateObject("Wscript.Shell")
    set fso=createobject("scripting.filesystemobject")
    strPath = M.CurrentDirectory
    if fso.FileExists("strPath\calc.exe") then  '这样应用路径对么?
    M.run "strPath\calc.exe"
    else
    MsgBox("可执行文件不存在!")
    end if
      

  4.   

    if fso.FileExists("strPath\calc.exe") then  '这样应用路径对么? 
    这里面的应该在system32下面,那就对,不是就不对。
      

  5.   


    strPath 是你当前的路径,也就是你这个文件所在的路径,如果你把它放到system32下面当然可以,或者你把calc.exe放到你当前的路径下。
    自己好好看看啊,不了解你的需求,其实很简单的,你在你当前目录创建一个.vbs文件,把上面的代码拷贝过去然后保存,双击就可以运行看效果了。
      

  6.   

    if fso.FileExists("strPath\calc.exe") then   这里的变量strPath应该如何应用,按这个应用,下来有错误!
      

  7.   

    ---------->试下吧。记忆改的
    dim fso
    dim strPath
    Set M = CreateObject("Wscript.Shell")
    set fso=createobject("scripting.filesystemobject")
    set strPath = M.CurrentDirectory
    if fso.FileExists(strPath+"\calc.exe") then  '这样应用路径对么?
    M.run strPath+"\calc.exe"
    else
    MsgBox("可执行文件不存在!")
    end if 
      

  8.   

    运行时提示错误如下:Error:缺少对象:'[string:"C:\program files\新建文件夹"]'
      

  9.   

    那么你的strPath就是这个路径了,那就建个这路径呗
      

  10.   

    可能吧。可能你的这个vb代码在哪里,那么那个exe也得在哪里?这个不懂,试试看就知道了。
      

  11.   


    你这个vbs文件在【C:\program files\新建文件夹】下,所以会那样。