Author |
Message |
veato
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:17 am Posts: 5550 Location: Nottingham
|
Anyone know a VB script that will create a folder on %homedrive% (this will be the logged on users network share mapped as U:) called 'favourites' and 'desktop shortcuts' (if they dont already exist) and then copy the logged on users favourites and shortcuts to these folders? I'm not in the least a programmer and to be honest hate it with a passion (yes, even little VB scripts - I'd rather lick a fat mans armpit) but will spend the day trawling Google. Any help appreciated. 
_________________Twitter Blogflickr
|
Wed Apr 21, 2010 8:46 am |
|
 |
EddArmitage
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 9:40 pm Posts: 5288 Location: ln -s /London ~
|
Possibly worth having a looksy on Superuser or ServerFault. Sorry I can't be more useful.
|
Wed Apr 21, 2010 9:08 am |
|
 |
finlay666
Spends far too much time on here
Joined: Thu Apr 23, 2009 9:40 pm Posts: 4876 Location: Newcastle
|
Does it have to be a VB script?
May be work looking at running a basic batch file on startup
_________________TwitterCharlie Brooker: Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.
|
Wed Apr 21, 2010 1:04 pm |
|
 |
veato
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:17 am Posts: 5550 Location: Nottingham
|
The script needs to look for the two folders on the network share. If they are present it moves onto the next part (copying the data over) or if not it creates the folders before moving on. Can a batch file do this? At the minute I've got VBSs to check for and/or create the folders which are run by a batch file also handling the copying of data: Dumb questions but.... 1) Can I combine the 2 VBS into 1? 2) In the scripts I've used the drive letter and path but would have prefered to use %homeshare%. I cannot make this work even with the help of Google  Does anyone know how?
_________________Twitter Blogflickr
|
Wed Apr 21, 2010 1:41 pm |
|
 |
opensvr
Has a life
Joined: Fri Apr 09, 2010 9:18 pm Posts: 17
|

Hi, you need to be very careful here - you have said you want to use the environment vairable "homedrive"
This is a system environment variable i.e. if you drop to a command prompt and run set you will see it already exists. for example on my PC %homedrive% is c: If you want anew env variable let me know.
So you can test this script, I have left a load of msgbox diagnostics in - remove or comment out as needed. Also uncomment the on "error resume next" lines when you are happy with it.
Good luck.
##########Copy below
'This script create a folder on %homedrive% (this will be the logged on users network share mapped as U:) 'called 'favourites' and 'desktop shortcuts' (if they dont already exist) and then copy the logged on users 'favourites and shortcuts to these folders?
'------------------------------------------------- Sub CreateDirs() 'on error resume next
Set objFso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Wscript.Shell") Set WshSysEnv = objShell.Environment("System")
strhomedrive = WshSysEnv("homedrive")
msgbox strhomedrive
'Make Favorites folder objFso.CreateFolder strhomedrive & "\favorites" if err.number = 58 then msgbox "'%homedrive%\favourites' already exists ..." end if
'Make desktop shortcuts folder objFso.CreateFolder strhomedrive & "\desktop shortcuts" if err.number = 58 then msgbox "'%homedrive%\desktop shortcuts' already exists ..." end if
end sub '----------------------------------------------------------------------------------
'---------------------------------------------------------------------------------- Sub copyfiles() 'on error resume next
Set objFso = CreateObject("Scripting.FileSystemObject") Set objShell = Wscript.CreateObject("Wscript.Shell")
Set WshSysEnv = objshell.Environment("System") strhomedrive = WshSysEnv("homedrive")
msgbox strhomedrive
strDesktop = objshell.SpecialFolders("Desktop") strFavorites = objshell.SpecialFolders("Favorites")
msgbox strdesktop & " " & strfavorites
Const OverwriteExisting = True
objFSO.CopyFile strDesktop & "\*.lnk" , strhomedrive & "\desktop shortcuts" , OverwriteExisting objFSO.CopyFile strFavorites & "\*.*" , strhomedrive & "\favorites" , OverwriteExisting
end sub '----------------------------------------------------------------------------------
CreateDirs msgbox "Finished setting Directory Structures" copyfiles msgbox "Finished copying files"
|
Wed Apr 21, 2010 2:16 pm |
|
 |
veato
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:17 am Posts: 5550 Location: Nottingham
|
I'm at home now and cant remember but it may have been homeshare it would be better pointed to. This by default is a users \\server\share I ran your script to test and everything was placed in C:\
_________________Twitter Blogflickr
Last edited by veato on Thu Apr 22, 2010 10:28 am, edited 1 time in total.
|
Wed Apr 21, 2010 4:45 pm |
|
 |
veato
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:17 am Posts: 5550 Location: Nottingham
|
Thanks for the help. I've been using what I've read here and what I've found on the t'internet with my own splash of blindly trying stuff unitl it works and I have something. In its current state it does 95% of what I need it to - although it might not be pretty I wondered if anyone can help with the final 5%? Basically where the files from the favorites folder are copied (highlighted in bold text below) only the files are copied and not any (sub)folders in that location
_________________Twitter Blogflickr
|
Thu Apr 22, 2010 10:26 am |
|
|