Reputation: 51
I have 2 scripts but could not combine them
Create a folder script
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
desktop path script
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
wscript.echo(strDesktop)
Con some one help me please ?
Upvotes: 2
Views: 8587
Reputation: 38775
Use .BuildPath to combine the Desktop folder path and the intended (sub)folder(name):
>> 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
Upvotes: 4