Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB script to create folder to a user profile

Posted on 2013-05-16
8
Medium Priority
?
541 Views
Last Modified: 2013-05-18
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
0
Comment
Question by:juniorval01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 39173454
have you tried using "%UserProfile% variable instead on Username?
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39173469
Can't you just add it in to the path, like:

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

~bp
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 600 total points
ID: 39173820
Or the .cloud might be the domain:
strFolder = "\\XXX.local\Site\Home$\%USERNAME%.%USERDOMAIN%\WINDOWS\Fonts"

Rob.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:juniorval01
ID: 39175501
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?
0
 
LVL 57

Accepted Solution

by:
Bill Prew earned 1400 total points
ID: 39175566
That's typically due to one of the higher level folders not already existing.  VB isn't like the DOS "mkdir" command, which will automatically create all higher level folders.  In VB you have to make sure each parent exists before creating children.

Typically there are two approaches to solving this.  One is to just shell out to a DOS command and use the MKDIR command for the folder creation.  The other is to use a function that walks down the folders in the path you want to ultimately create and adds any missings ones using VB commands.

I know Rob is up on all of this and can guide you in the code needed, so I won't interfere unless he can't get to this and then I'll lend a hand.  Here's some example code if you want to tackle it on your own.

http://stackoverflow.com/questions/4407386/help-to-create-folder1-folder2-in-windows-using-vbscript-both-the-folders-not

~bp
0
 

Author Closing Comment

by:juniorval01
ID: 39175753
@BP,

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

Many thanks to BP and Rob!
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 39175889
Welcome, glad that helped.

~bp
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 39176997
Thanks Bill for the support.  Thanks JV for the assist points.  Glad to help.

Rob.
0

Featured Post

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question