2

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 ?

1
  • 1
    Which part specifically are you struggling with? Commented Jul 23, 2015 at 20:04

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

thank you Ekkehard.Horner but if I try to run it give me "WshShell undefined" error I am Novice maybe my failure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.