0

現在のユーザーのデスクトップへのパスを返すスクリプトが必要です。これで、WScript で実行できることがわかりました。

var WshShell = WScript.CreateObject("WScript.Shell");
         strDesktop = WshShell.SpecialFolders("Desktop");

しかし、私のスクリプトでは、WScript を使用できないため、これは機能しません。しかし、以下のように shell.application オブジェクトを使用できます。

 dim objShell
        dim ssfWINDOWS
        dim objFolder

        ssfWINDOWS = 0
        set objShell = CreateObject("shell.application")
            set objFolder = objshell.BrowseForFolder(0, "Example", 0, ssfWINDOWS)
                if (not objFolder is nothing) then
                Set objFolderItem = objFolder.Self
                    g_objIE.Document.All("logdir").Value = objFolderItem.path
                end if
            set objFolder = nothing
        set objShell = nothing

「BrowseForFolder」ではなく、現在のユーザーのデスクトップのパスを簡単に返すことができる構文は何ですか?

IEは行を置き換えます

set objFolder = objshell.BrowseForFolder(0, "Example", 0, ssfWINDOWS)

の等量で。

strDesktop = WshShell.SpecialFolders("Desktop");

乾杯

アーロン

4

2 に答える 2

3

名前空間メソッドを試してください:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(&H10&)

&H10& は、デスクトップの特別なフォルダー定数です。すべての特殊フォルダー定数のリストについては、technetを参照してください。

于 2011-11-08T14:17:01.807 に答える
3

使用する必要があります:Shell.Namespace(...).Self.Path

Const ssfDESKTOPDIRECTORY = &h10
Set oShell = CreateObject("Shell.Application")
strDesktop = oShell.NameSpace(ssfDESKTOPDIRECTORY).Self.Path

WScript.Echo strDesktop


しかし、私のスクリプトでは、WScript を使用できないため、これは機能しません。

は未定義なWScript.CreateObject(...)ので使えないということですか?WScriptその場合は、CreateObject("WScript.Shell").SpecialFolders("Desktop")代わりに使用できます。CreateObject と Wscript.CreateObject の違いを参照してください。.

于 2011-11-08T14:17:39.753 に答える