x404.co.uk http://www.x404.co.uk/forum/ |
|
VB Script Experts http://www.x404.co.uk/forum/viewtopic.php?f=4&t=7868 |
Page 1 of 1 |
Author: | veato [ Wed Apr 21, 2010 8:46 am ] |
Post subject: | VB Script Experts |
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. ![]() |
Author: | EddArmitage [ Wed Apr 21, 2010 9:08 am ] |
Post subject: | Re: VB Script Experts |
Possibly worth having a looksy on Superuser or ServerFault. Sorry I can't be more useful. |
Author: | finlay666 [ Wed Apr 21, 2010 1:04 pm ] |
Post subject: | Re: VB Script Experts |
Does it have to be a VB script? May be work looking at running a basic batch file on startup |
Author: | veato [ Wed Apr 21, 2010 1:41 pm ] | ||||||||||||||||||||||||||||||||||||
Post subject: | Re: VB Script Experts | ||||||||||||||||||||||||||||||||||||
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 ![]() |
Author: | opensvr [ Wed Apr 21, 2010 2:16 pm ] |
Post subject: | Re: VB Script Experts |
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" |
Author: | veato [ Wed Apr 21, 2010 4:45 pm ] | |||||||||
Post subject: | Re: VB Script Experts | |||||||||
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:\ |
Author: | veato [ Thu Apr 22, 2010 10:26 am ] | |||||||||
Post subject: | Re: VB Script Experts | |||||||||
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 ![]()
|
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |