通过 Vbscript 在桌面上创建一个文件夹

Create a folder on desktop via Vbscript

我有 2 个脚本,但无法组合它们

创建文件夹脚本

Option Explicit
Dim objNetwork, objComputer
Dim objFSO, objFSOText, objFolder, objFile
Dim strDirectory, strFile, MakeObject

strDirectory = "Folder"
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists(strDirectory) Then
Wscript.Echo strDirectory & " already exists"
Else
'Below is the added line
Set objFolder = objFSO.CreateFolder(strDirectory)
Wscript.Echo "The folder " & strDirectory & " has just been created"
End if

Wscript.Quit

桌面路径脚本

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
wscript.echo(strDesktop)

有人帮我吗?

使用 .BuildPath 组合桌面文件夹路径和预期的(子)文件夹(名称):

>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set WshShell = WScript.CreateObject("WScript.Shell")
>> strDirectory = "Folder"
>> strDirectory = objFSO.BuildPath(WshShell.SpecialFolders("Desktop"), strDirectory)
>> WScript.Echo strDirectory
>>
C:\Documents and Settings\eh\Desktop\Folder