我有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)
请一位有人帮帮我吗?
答案 0 :(得分:1)
使用.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