Hey Guys,
I'm sure this is an easy fix but I can't seem to figure it out. I am trying to create a sub directory within a users home folder but can't seem to get the sub folder created. Granted, this sub folder is based on the variable name of the user that logs in maybe that is the issue? Since it isn't static? Below is the code minus the errors I get.
Dim objFSO, objFolder, strComputer, strDirectory, objNet, strTest, objoutlook, objNS, objFName, objTextFile, pstFiles, pstName, strPath, pstFolder, strLocal
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\supertest\pst_script_log.txt ") Then
Wscript.Quit
Else
strTest = "C:\supertest"
Set objFolder = objFSO.CreateFolder(strTest)
End If
' get username
Dim WshNetwork: Set WshNetwork = wscript.CreateObject("WScript.Network")
Dim user: user = LCase(WshNetwork.UserName)
Set WshNetwork = Nothing
' network path to write pst files to
strLocal = "E:\Local_PST"
strDirectory = "E:\dumb\" & user & "\" ' <-- im trying to create the sub dir "Local_PST" after the user variable, isn't working.
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Note If..Exists. Then, Else ... End If construction
If objFSO.FolderExists(strDirectory) Then
'Open the Folder if it's already created
Set objFolder = objFSO.GetFolder(strDirectory)
WScript.Echo strDirectory & " already created "
'WScript.Quit
ELSE
Set objFolder = objFSO.CreateFolder(strDirectory)
Set objFolder = objFSO.CreateFolder(strLocal)
WScript.Echo "Just created " & strDirectory
End If