Sign in with
Sign up | Sign in
Your question

VBScript to copy shortcuts

Last response: in Windows 2000/NT
Share
April 4, 2005 2:04:03 AM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

I need to create a VBScript that will:
Check the logon user's settings to see if some QuickLaunch icons
exist and if not to copy them.
The problem is I don't know VBScript that well (and it needs to be in
VBScript I have been told already.)

So... can someone tell me where I can get info on doing this? I can't
seem to find a reference on how to do this.

In a nutshell I will need to:
1) Get the login user's name
2) Check to see if the Quick Launch icons exist in the Documents &
Settings\%UserName%\Application Data\Microsoft\Internet Explorer\Quick
Launch folder
3) if not there copy them to the Quick Launch folder

I also need to do this for the desktop icons as well (these will be
group policy login scripts.)

Once I understand this I will attempt to mimic roaming profiles
without the hassle of using roaming profiles (some bugs like it
copying the printer(s) over can be avoided if I just use scripts.)

Any hints or code samples are appreciated!

-Fran-
Anonymous
April 4, 2005 10:02:07 AM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

"Fran >" <<fran> wrote in message
news:78b151li3p6nppfk9iap5kd4lrir8m3m36@4ax.com...
> I need to create a VBScript that will:
> Check the logon user's settings to see if some QuickLaunch icons
> exist and if not to copy them.
> The problem is I don't know VBScript that well (and it needs to be in
> VBScript I have been told already.)

pt is giving good advice about VBScript.

Allow me to add that you can investigate the
ScriptoMatic at Microsoft by searching Google:

[ scriptomatic site:microsoft ]

Also, since you don't give a reason except for
being "told" it needs to be in VBScript:

For something this simple and file focused,
a simple batch file using XCOPY will work
as well in all likelyhood.


--
Herb Martin


"Fran >" <<fran> wrote in message
news:78b151li3p6nppfk9iap5kd4lrir8m3m36@4ax.com...
> I need to create a VBScript that will:
> Check the logon user's settings to see if some QuickLaunch icons
> exist and if not to copy them.
> The problem is I don't know VBScript that well (and it needs to be in
> VBScript I have been told already.)
>
> So... can someone tell me where I can get info on doing this? I can't
> seem to find a reference on how to do this.
>
> In a nutshell I will need to:
> 1) Get the login user's name
> 2) Check to see if the Quick Launch icons exist in the Documents &
> Settings\%UserName%\Application Data\Microsoft\Internet Explorer\Quick
> Launch folder
> 3) if not there copy them to the Quick Launch folder
>
> I also need to do this for the desktop icons as well (these will be
> group policy login scripts.)
>
> Once I understand this I will attempt to mimic roaming profiles
> without the hassle of using roaming profiles (some bugs like it
> copying the printer(s) over can be avoided if I just use scripts.)
>
> Any hints or code samples are appreciated!
>
> -Fran-
Anonymous
April 4, 2005 12:09:10 PM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

The place to start is the Microsoft Scripting centre:
-- http://www.microsoft.com/technet/scriptcenter/default.m...


Here's a couple of little, example bits of code that I'm able to lay my
hands on this early in the morning...
There's three here. May not all be of relevance, but are to do with
manipulating files in one way or another. Some of the bits you want are in
there such as getting environment variables, checking if a folder exists,
etc.


' An example of using environment variables when copying files.
' In this script a shortcut 'shortcut.lnk' is copied to the desktop
' of the %username% user profile.

set objFso=createObject("scripting.fileSystemObject")
set objWShell=wScript.createObject("WScript.Shell")

usrName=objWShell.expandEnvironmentStrings("%USERNAME%")

strFileToCopy="shortcut.lnk"
strFolder="C:\Documents and Settings\"&usrName&"\Desktop"

if objFso.folderExists(strFolder) then
objFso.copyFile strFileToCopy,strFolder&"\",true
end if



' exDeleteMultipleFilesOfSameType.vbs
'
' An example of how to delete multiple files of the same type in a folder.
' Simple script that deletes any files of the type defined in FILE_TYPE in
the
' folder defined in FOLDER_NAME
'
' Paul Williams, msresource.net, February 2005.
'
const FOLDER_NAME="C:\Documents and Settings\All Users\Desktop"
const FILE_TYPE="Shortcut"

set objFso=createObject("scripting.fileSystemObject")

if objFso.folderExists(FOLDER_NAME) then
set folder=objFso.getFolder(FOLDER_NAME)
set files=folder.files

for each file in files
if file.type=FILE_TYPE then
file.delete(true)
end if
next
end if



' An example of how to look for files, in a given folder, that are
' older than a set number of days.
'
' The folder to query is set using the FOLDER_NAME constant.
' The number of days difference is set using the AGE_DIFFERENCE constant
'
' Paul Williams, February 2005.
'
'
const FOLDER_NAME="C:\tmp\vbsctest"
const AGE_DIFFERENCE=7

set objFso=createObject("scripting.fileSystemObject")

if objFso.folderExists(FOLDER_NAME) then
set folder=objFso.getFolder(FOLDER_NAME)
set files=folder.files

'strDate=date
strDate=now

for each file in files
strFileDate=file.dateLastModified

d=int(strDate-strFileDate)

if d>AGE_DIFFERENCE then
echo(" File ["&file.name&"] has not been modified in "&d&"
days."&vbCrLf)
echo(vbTab&"This is older than the "&AGE_DIFFERENCE&_
" day allowed difference."&vbCrLf)

echo(vbTab&"Today's date: "&strDate)
echo(vbTab&file.name&" last modified stamp: "&strFileDate&vbCrLf)

echo(vbTab&"Time difference in days: "&d)

d=d*24
echo(vbTab&"Time difference in hours: "&d)

d=d*60
echo(vbTab&"Time difference in minutes: "&d)

d=d*60
echo(vbTab&"Time difference in seconds: "&d&vbCrLf)
end if

echo("")
next
end if



' *********************************************************************
' echo(string messageToEcho)
'
' Sub routine simply echos the passed string.
' Sub used for outputting all information to the screen/ console
'
' *********************************************************************
Private Sub echo(strMessage)
wscript.echo strMessage
End Sub



--

Paul Williams

http://www.msresource.net/
http://forums.msresource.net/
Related resources
April 6, 2005 7:59:12 PM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

I tried the XCOPY idea yesterday and it didn't work. I suspect now
(after reading MS's site on login and startup scripts) that this is a
user rights issue.

So.... how do I copy these icons to a user's account settings if the
user's account doesn't have rights to do that? Can I use the startup
login? Does it know the user when it runs???

Thoughts?

-Fran-

>"Fran >" <<fran> wrote in message
>news:78b151li3p6nppfk9iap5kd4lrir8m3m36@4ax.com...
>> I need to create a VBScript that will:
>> Check the logon user's settings to see if some QuickLaunch icons
>> exist and if not to copy them.
>> The problem is I don't know VBScript that well (and it needs to be in
>> VBScript I have been told already.)
>
>pt is giving good advice about VBScript.
>
>Allow me to add that you can investigate the
>ScriptoMatic at Microsoft by searching Google:
>
> [ scriptomatic site:microsoft ]
>
>Also, since you don't give a reason except for
>being "told" it needs to be in VBScript:
>
>For something this simple and file focused,
>a simple batch file using XCOPY will work
>as well in all likelyhood.
Anonymous
April 7, 2005 10:05:17 AM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

"Fran >" <<fran> wrote in message
news:g7j8519ipq3jvt7o7jlfq1936u1dlu0rsl@4ax.com...
> I tried the XCOPY idea yesterday and it didn't work. I suspect now
> (after reading MS's site on login and startup scripts) that this is a
> user rights issue.

That would likely be permissions.

> So.... how do I copy these icons to a user's account settings if the
> user's account doesn't have rights to do that? Can I use the startup
> login? Does it know the user when it runs???

You will need the account that copies to have read on
the source, and write/modify on the destination directory,
but if you are copying to the users profile the user will
have that on the destination.

It would seem reasonable to give the users "read" on the
source files.
April 7, 2005 3:05:02 PM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

I'm not sure I understand what you're saying here. But here's my
situation:

When I add a new user to our network (AD domain) I need to copy over
some desktop icons (links to server apps) and make similar quick
launch icons in the quick launch bar
(additionally I need to be able to set the "display quick launch bar"
in Windows XP but I think this is a GPO setting.)

I have tried XCOPY scripts but they fail when a new (Power User) is
added and logs on for the first time.

How can I get around this? When you say the account that copies have
read on source...I just need to create a permission to this
server\icons folder?

-Fran-

>> I tried the XCOPY idea yesterday and it didn't work. I suspect now
>> (after reading MS's site on login and startup scripts) that this is a
>> user rights issue.
>
>That would likely be permissions.
>
>> So.... how do I copy these icons to a user's account settings if the
>> user's account doesn't have rights to do that? Can I use the startup
>> login? Does it know the user when it runs???
>
>You will need the account that copies to have read on
>the source, and write/modify on the destination directory,
>but if you are copying to the users profile the user will
>have that on the destination.
>
>It would seem reasonable to give the users "read" on the
>source files.
>
Anonymous
April 8, 2005 12:43:42 AM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

"Fran >" <<Fran> wrote in message
news:p 3ka51179fm6kjtvfn3ihb6tutnvuru6sc@4ax.com...
> I'm not sure I understand what you're saying here. But here's my
> situation:
>
> When I add a new user to our network (AD domain) I need to copy over
> some desktop icons (links to server apps) and make similar quick
> launch icons in the quick launch bar

In that case (new users), why not just copy it over NOW to the
"Default" profile of every machine?
(And be done with it.)

> (additionally I need to be able to set the "display quick launch bar"
> in Windows XP but I think this is a GPO setting.)
>
> I have tried XCOPY scripts but they fail when a new (Power User) is
> added and logs on for the first time.

Why do they "fail"? How do the "fail"?
What happens?


> How can I get around this?

Fix it so they don't "fail" -- whatever that means.

> When you say the account that copies have
> read on source...

On the source of the files you are going to copy.

> I just need to create a permission to this
> server\icons folder?

Certainly -- although I don't know if that is the
entire problem it would be a requirement.

A user cannot copy unless they have READ on
files and on the share.

And unless they have write to the destination
directory.

> -Fran-
>
> >> I tried the XCOPY idea yesterday and it didn't work. I suspect now
> >> (after reading MS's site on login and startup scripts) that this is a
> >> user rights issue.
> >
> >That would likely be permissions.
> >
> >> So.... how do I copy these icons to a user's account settings if the
> >> user's account doesn't have rights to do that? Can I use the startup
> >> login? Does it know the user when it runs???
> >
> >You will need the account that copies to have read on
> >the source, and write/modify on the destination directory,
> >but if you are copying to the users profile the user will
> >have that on the destination.
> >
> >It would seem reasonable to give the users "read" on the
> >source files.
> >
>
April 8, 2005 1:36:03 AM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

"Fail" means that after the user logs on there are no new icons.

How can I modify the default user profile and be done with it? There
are many things I want to set as a default for this and all new
machines we install but I'm not familiar with that.

The "everyone" group has read access to the share where the icons are
stored on the server (two folders: "desktop" and "QuickLaunch")

-Fran-
Anonymous
April 9, 2005 8:39:33 AM

Archived from groups: microsoft.public.win2000.active_directory (More info?)

"Fran >" <<Fran> wrote in message
news:o 9rb511tok1cfte7jims5r2m1rca4gbdur@4ax.com...
> "Fail" means that after the user logs on there are no new icons.

So what happens during the batch job?

File not found? Permissions problem? etc?


> How can I modify the default user profile and be done with it? There
> are many things I want to set as a default for this and all new
> machines we install but I'm not familiar with that.

Setup and test a profile, then just copy it over the
current one.

Best is probably to rename the old Default (in case
you want it back) before copying or renaming the
new one into place.

Also, be certain to set permissions so that Everyone
(or Authenticated Users) can read ALL files in that
profile -- it is copied whenever a user does not have
a profile or does not have access to their roaming
profile.

Remember that Default only affects users who do not
yet have a profile one a particular machine for local
profiles, or who do not have the profile server available
to download their roaming profile.

> The "everyone" group has read access to the share where the icons are
> stored on the server (two folders: "desktop" and "QuickLaunch")

They would also need Read to the FILES and directories,
assuming you are using NTFS on the server file system.

They would need to be properly authenticated so that the
Read access on NTFS & SHARE are effective.

> -Fran-
!