Hi guys,

Can anyone tell me if there is a variable for .vbs files that will allow the code to find the llogged on user?

Ill explain a little better...

I have a code that copys files and folders to a network drive, however it only works when i am logged on due to this piece of the code:

src = "C:\documents and settings\me\Favorites
dest = "z:\"

This code only works when "me" is logged on and i was wondering if there was a variable i could add in there that would look for the logged on username and insert that...

For example a .bat file or a .com file to do the same task has a variable of %USERNAME% or %USERPROFILE%... that allows the code to go to the folder of the logged on user.... so does anyone know if ther is a variabel i could put into the line of code in my .vbs file to allow it to do the same?

if you could post a slice of code that will do this or point me to a resource i can learn from id be most appreciative.

Cheers and thanks in advance...

dim wsh
set wsh = createobject("WScript.Shell")
login_name = wsh.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Logon User Name")

src = "C:\documents and settings\" & login_name & "\Favorites"

Here is a method to keep using your dos CLI Variables:

Sub Main
Dim wsh, fs, profile
set wsh = createobject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
profile = wsh.ExpandEnvironmentStrings("%UserProfile%")

'Copy Files
fs.CopyFile "C:\WINDOWS\win.ini", "" & profile & "\WINDOWS\", True End Sub