0

OK so I am writing a super cool vbscript/HTA file. All i want to do is to

List all local users names in the computer in a list box ( I can do it already) and then For each user in the list box, copy their desktop,mydocuments,videos,pictures,music to a destination folder of my choice ( say d:\backupdestination)

Now most of the script IS working and i also know that I can use the &H5& type constants to access the special folders I mentioned above for the LOGGED-IN user i.e. the person running the script.

Now I donot know where the other users profile files are, they could be in c:\users\John ( the usual vista/win 7) OR they could be anywhere on the disk ( maybe john moved his profile to d:).

So I just need to know how to tell the script to copy all the user profiles on the computer to my chosen destination.

The code below for example copies My Pictures folder for the CURRENT, LOGGED-IN user, how do I modify it so it copies all users' profiles?

Const MY_PICTURES = &H27&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_PICTURES)
Set objFolderItem = objFolder.Self 
Wscript.Echo objFolderItem.Name & ": " & objFolderItem.Path 

Any help will be appreciated !!!!!!!! thx.

Merci.

Le Prince De Dhump

LePrinceDeDhump
  • 436
  • 6
  • 18

1 Answers1

0

You have two choices :

1, read the definition of these special folders from the register keys "HKEY_USER\user SID\SOFTWARE\MICROSOFT\Windows\Current Version\Explorer\User shell folders". Use "winmgmts:\.\root\default:StdRegProv" to enumerate keys.

2, use the "run" method of "wscript.shell" object to run "rundll32.exe". Then you can use the "LogonUser" API function to get a token (if you know his password) and use the "ImpersonateLoggedOnUser" function to run as another user profile. You done need to modify your existing code to get all his special folders.

well7m
  • 21
  • 3