如何在VBScript中获取文件的标准路径? [英] How to get the fully qualified path for a file in VBScript?

查看:253
本文介绍了如何在VBScript中获取文件的标准路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Shell.Application对象,该对象允许我编写zip文件的脚本.

I am using the Shell.Application object, which allows me to script creation of a zip file.

但是为了使其正常工作,我需要zip文件的完整路径. File.zip不起作用.即使脚本在找到文件的相同目录中运行,我也需要c:\the\full\path\file.zip.

But in order for this to work, I need to full path of the zip file. File.zip doesn't work. I need c:\the\full\path\file.zip, even if the script is running within the same directory where the file is found.

如何在 VBScript 中获取文件的完整路径?

How can I get the full path of a file in VBScript?

类似cmd.exe Shell中的%~fI扩展.

Something like the %~fI expansion in the cmd.exe shell.

推荐答案

Scripting.FileSystemObject ,有一种叫做

On Scripting.FileSystemObject, there's a method called GetAbsolutePathName that does this.

这对我有用:

Dim folderName
folderName = "..\.."

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim fullpath
fullpath = fso.GetAbsolutePathName(folderName)

WScript.Echo "folder spec: " & folderName
WScript.Echo "fullpath:    " & fullpath

这篇关于如何在VBScript中获取文件的标准路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆