OK, I'm working on an install package that requires 3 files to be copied down to a specific directory within all user profiles that exist on a system (not the All Users profile) after the install completes. These files pre-configure certain settings within the app and disable other options that I don't want the user to have access to. I have spoken with the vendor and apparently there is no way to store these files in a central, shared location; they have to exist within the user profile for each user that logs into the system.

What I'm hoping for is a VB script to run after the install completes that can create a folder within every user profile that exists on the system, then copy the 3 files down from the install point. It would also be nice if someone could help me figure out a way to have the files copy over automatically for any new user profiles that are created on the system after the app is installed.

FYI, I'm not totally script illiterate. I know how to write a script to create a directory and I know how to write a script to copy files to a directory, I just haven't mastered VBS well enough to accomplish more complex tasks like the above mentioned. For instance, I can make a script that creates a folder called C:\temp and have it copy the files to there but I can't figure out how to use path variables to have the script create a folder in all existing profiles and copy the same files to all of them... and I definitely have no idea how to setup something to copy the same files to any new user profile that might get created.

Any assistance would be greatly appreciated.
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


I had to deal with similar kind of stuff in one of my packages. What I did was included the files in the package itself, say to INSTALLDIR and then copied those files to the required folder under userprofile using a similar vbscript. I also included ActiveSetup regsitry key to run the script everytime a new user logs onto the system.

There is another way of doing this (depending on type of files)you can include those files into a user settings based component in your package so that whenever any user uses that application for the first time there is a repair of the application and the required files are copied to the location you want.

I assume you are versed with application packaging concepts and are able to use either Installshield or Wise Package Studio

First Secnario:

Create a new component and include the files and the vbscript in that component. Also include the ActiveSetup Registry key with the StubPath set to your VBScript in this component, Assign this component as the child of a feature that would always be installed.

This would execute your script for every user that logs onto the system for the first time and hence the required files and directory structure would be made available to him before he uses your application.

Second Secnario:

Use the instructions as in para 1 for First Secnario except that you do not need that script. In this case you can add the desired folder structure in your package it self and then once the repair takes place for the application, desired result would be there on the system.

Hope this helps.
Answered 02/18/2009 by: AssmbLLYCoder
Senior Yellow Belt

Please log in to comment
I think the ActiveSetup/user component scenario is best, rather than blindly copying to every user profile. After all, you're only interested in settings for the applications themselves so it makes sense to populate folders only for users of those applications. Otherwise, you're going to have to build in checks for local users like 'Administrator', 'LocalService', NetworkService' and so on. Ugly...

As for how to script it - which your first respondent neatly side-stepped! :) - well, there are gazillions of samples all over the web but this site http://www.cruto.com/resources/vbscript/vbscript-examples/vbscript-sitemap.asp is one of the better ones.

As a VBScript reference, it's hard to beat DevGuru http://www.devguru.com/technologies/vbscript/home.asp

Hint: You'll need the Shell object to access the environment variable %USERPROFILE% (avoid using hard-coded references to, for example, 'C:\Documents and Settings' which of course has changed in Vista...)

[puts on drum to bang...] - again!
Since you're new to scripting, I'll take this opportunity to say that I cannot emphasise enough the importance of defensive programming.
- As mentioned above, avoid hard-coded values where possible.
- ALWAYS trap errors. In script (and in all forms of programming) assume NOTHING. For example, your script should check that the shell object got created - If IsObject(objShell) Then - before it tries to use it. Check that each part of the parent folder of the tree you're trying to create exists before creating a child folder AND that the child got created, and so on. Sure, it makes your script more complex but it also makes it a lot more bullet-proof.

Lastly, if you want to avoid reams and reams of 'If Err.Number <> 0 Then' constructs to add error-trapping, check out the various samples from Microsoft which use Bruce McKinney's BugAssert sub-routine. It's a neat solution.
Answered 02/18/2009 by: VBScab
Red Belt

Please log in to comment
I'd create a new component with the 3 files in it, give it a path of where the files need to be i.e. windows\profiles\application data\program name
then create a registry key in say HKEY_CURRENT_USER\Software\Program Name\Installed with a value of 1, move that into the above component

Then change the Key Path of the new component to Registry and set it to the new registry key

That way when one of the shortcuts is run (If they are advertised) self-repair will initiate and all user based files/registry keys will be installed
Answered 02/18/2009 by: ditch_nz
Purple Belt

Please log in to comment