Link to home
Create AccountLog in
Avatar of juniorval01
juniorval01

asked on

VB script to create folder to a user profile

Hello,

I have this simple VB script to create a folder to user's profile which works to some extent. The problem I am running into is the profiles in the home directory have a (.cloud) extension (example= jondoe.cloud) The VB script below just recognizes the user name, but not the .cloud. Any ideas anyone??

Dim objFSO, strFolder
strFolder = "\\XXX.local\Site\Home$\%USERNAME%\WINDOWS\Fonts"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists(strFolder) Then
   objFSO.CreateFolder(strFolder)
End If

Thanks,

JV
Avatar of santoshmotwani
santoshmotwani
Flag of Australia image

have you tried using "%UserProfile% variable instead on Username?
Avatar of Bill Prew
Bill Prew

Can't you just add it in to the path, like:

strFolder = "\\XXX.local\Site\Home$\%USERNAME%.cloud\WINDOWS\Fonts"

~bp
SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of juniorval01

ASKER

Thanks guys for the responses back.

@Rob, I have added the .%USERDOMAIN% and I was able to navigate to the location which is great. But it wont create the folder "FONTS".

Line: 5
Char: 4
Error: Path not found
Code: 800A004C

Any ideas?
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
@BP,

I went ahead and went with the info you sent me and worked as you expected.

Many thanks to BP and Rob!
Welcome, glad that helped.

~bp
Thanks Bill for the support.  Thanks JV for the assist points.  Glad to help.

Rob.