Re: help writting script to copy file to every desktop
- From: "Dave Allen" <nomail@xxxxxxxxxx>
- Date: Fri, 14 Sep 2007 10:19:15 -0700
Thankx Mike but a few things here
The infrastructure department at my company is Nazi about access to group policy or the login scripts
so those 2 avenues are not a possibility.
In a way you can say I am in desktop support.
I have admin rights over every desktop but limited access to servers.
What I envisioned writing was a script that would just copy to every machine that was powered up and access the C$ share
"Mike Cook" <mcook@xxxxxxxxxxxx> wrote in message news:CF8BB163-5CFB-4314-A243-2D2AF0CEB863@xxxxxxxxxxxxxxxx
Dave.
Here is a sample script that I use. I added the script to the policy assigned to the OU. You should be able to limit the scope of the copy by creating multiple versions of this script and assign them to the group policy assigned to each AD site. If site level isn't good enough, you can use a WMI query to get the computer name and make the logic flow that way. I only have a couple of sites, so I let the NETLOGON share handle the replication of the shortcuts for me. Each shortcut is only 1KB each, so the extra replication traffic is nothing.
A quick item to point out, the Scripting.FileSystemObject handles folders differently from files. If the path you send to the object ends with a backslash, that is indicating a folder. If you send a path that doesn't end with a backslash, it is a file. You will get different methods, collections, and properties for a file than you will for a folder.
Const PATH = "\\Server1\shortcut$\Division\Department\"
' Set a constant to look for the UNC to where the shortcuts are located, trailing backslash is neccessary
Const OverwriteExisting = TRUE
' Set a constant for the FileSystemObject to overwrite if necessary
set WshShell = WScript.CreateObject("WScript.Shell")
' Create a wscript.shell object to get the special folder of desktop
strDesktop = WshShell.SpecialFolders("desktop")
' Assign a string variable to the path to the user's desktopSet fso = CreateObject("Scripting.FileSystemObject")
' Create a FileSystemObject to check if the shortcut exists
Set f = fso.GetFolder(PATH)
' Get the folder object
Set fc = f.Files
' Create a collection of files in the folder object
For Each f1 in fc
' Start the loop
strItem = f1.name
If not FSO.FileExists(strDesktop & "\" & strItem) Then
' Check to see if the shortcut exists on the desktop
Set objShortcut = FSO.GetFile(PATH & strItem)
objShortcut.Copy strDesktop & "\" & strItem, OverwriteExisting
' If check fails, set a FileSystemObject to the shortcut on the network and copy it to the desktop
End If
Next
"Dave Allen" <nomail@xxxxxxxxxx> wrote in message news:ec$VM7h9HHA.3940@xxxxxxxxxxxxxxxxxxxxxxxI have multiple offices in my domain
In every office the desktop computer name is prefixed with the office's name
For example LA = Los Angles, NY, etc....
I need to write a .vbs that can copy a file to every machine's C: drive
based on the machine's name
I'd like to run it with command line variables like this
Domaincopy.vbs NY1- C:\Defrag.exe "C:\Documents and Settings\All
Users\Desktop\"
- Follow-Ups:
- Re: help writting script to copy file to every desktop
- From: Mike Cook
- Re: help writting script to copy file to every desktop
- References:
- help writting script to copy file to every desktop
- From: Dave Allen
- Re: help writting script to copy file to every desktop
- From: Mike Cook
- help writting script to copy file to every desktop
- Prev by Date: Querying Active Directory using VB?
- Next by Date: Scripting newbie, please help..
- Previous by thread: Re: help writting script to copy file to every desktop
- Next by thread: Re: help writting script to copy file to every desktop
- Index(es):
Relevant Pages
|