Vbscript VBS-找不到文件
如果我的电脑在目录中有outlook.exe(它有),我会尝试更改,但当运行代码FileExists时,会立即返回false,这会使我显示一条消息,说明文件不存在。你能帮我吗Vbscript VBS-找不到文件,vbscript,Vbscript,如果我的电脑在目录中有outlook.exe(它有),我会尝试更改,但当运行代码FileExists时,会立即返回false,这会使我显示一条消息,说明文件不存在。你能帮我吗 Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject( "WScript.Shell" ) outlook15 = "%ProgramFiles(x86)%\Microsoft Office\Off
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject( "WScript.Shell" )
outlook15 = "%ProgramFiles(x86)%\Microsoft Office\Office15\outlook.exe"
If (fso.FileExists("%ProgramFiles(x86)%\Microsoft Office\Office15\OUTLOOK.exe")) Then
msgbox outlook15 & " exists."
Else
msgbox outlook15 & "doesn't exists."
End If
您需要使用
ExpandEnvironmentStrings
将%程序文件(x86)%
转换为正确的路径
strPath = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
outlook15 = strPath & "\Microsoft Office\Office15\outlook.exe"
If fso.FileExists(outlook15) Then
msgbox outlook15 & " exists."
Else
msgbox outlook15 & " doesn't exist."
End If
您需要使用
ExpandEnvironmentStrings
将%程序文件(x86)%
转换为正确的路径
strPath = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
outlook15 = strPath & "\Microsoft Office\Office15\outlook.exe"
If fso.FileExists(outlook15) Then
msgbox outlook15 & " exists."
Else
msgbox outlook15 & " doesn't exist."
End If
您需要使用
ExpandEnvironmentStrings
将%程序文件(x86)%
转换为正确的路径
strPath = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
outlook15 = strPath & "\Microsoft Office\Office15\outlook.exe"
If fso.FileExists(outlook15) Then
msgbox outlook15 & " exists."
Else
msgbox outlook15 & " doesn't exist."
End If
您需要使用
ExpandEnvironmentStrings
将%程序文件(x86)%
转换为正确的路径
strPath = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
outlook15 = strPath & "\Microsoft Office\Office15\outlook.exe"
If fso.FileExists(outlook15) Then
msgbox outlook15 & " exists."
Else
msgbox outlook15 & " doesn't exist."
End If
好的,谢谢,它成功了,但是现在当它为真时,尝试用
WshShell.Run(outlook15)
打开Outlook,它说“系统找不到指定的文件”,这是因为Run()
函数需要在包含空格的任何路径周围加引号。改为使用WshShell.Run Chr(34)&outlook15&Chr(34)
。好的,谢谢你,它起作用了,但是现在如果是真的,请尝试使用WshShell.Run(outlook15)
打开Outlook,因为Run()
函数需要在包含空格的任何路径周围加引号。改为使用WshShell.Run Chr(34)&outlook15&Chr(34)
。好的,谢谢你,它起作用了,但是现在如果是真的,请尝试使用WshShell.Run(outlook15)
打开Outlook,因为Run()
函数需要在包含空格的任何路径周围加引号。改为使用WshShell.Run Chr(34)&outlook15&Chr(34)
。好的,谢谢你,它起作用了,但是现在如果是真的,请尝试使用WshShell.Run(outlook15)
打开Outlook,因为Run()
函数需要在包含空格的任何路径周围加引号。改用WshShell.Run Chr(34)&outlook15&Chr(34)
。