VBScript Macro getParentFolder Name

前端 未结 2 364
清歌不尽
清歌不尽 2021-01-24 17:06

I am trying to create a vbscript macro which would get the folder location in which the macro is stored and create the output files into the same folder. I am using the below co

2条回答
  •  青春惊慌失措
    2021-01-24 17:26

    There is a difference between the current directory ('where you are when you start the process') and the script's directory:

    >> WScript.Echo 0, goFS.GetAbsolutePathName(".\")
    >> WScript.Echo 1, goWS.CurrentDirectory
    >> WScript.Echo 2, goFS.GetParentFolderName(WScript.ScriptFullName)
    >>
    0 C:\Documents and Settings\eh
    1 C:\Documents and Settings\eh
    2 M:\bin
    

    (I called my REPL/Interactive VBS shell that resides in m:\bin from my home directory)

    I don't know if "Cubes_Macro_V5.zmc" is a VBScript file (with a special extension that is loaded by whatever agent you use via w|cscript.exe), but check if WScript.ScriptFullName has the expected content and apply .GetParentFolderName.

    If that fails, you need to determine the folder that your agent uses for macros and feed that directory to .BuildPath.

    On second thought:

    Voodoo but easy to test: Does

    WScript.Echo 0, goFS.GetAbsolutePathName(".\Cubes_Macro_V5.zmc")
    

    deliver the desired result?

提交回复
热议问题