Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Help

Status
Not open for further replies.

tex52

IS-IT--Management
Apr 14, 2005
45
US
I need a script to copy files from a network location to multiple users desktops. Any help would be appreciated.
 
Here is a template I made that will have enough to accomplish what you need. I fixed the copy section for you.
Code:
Dim varToday, Verify, LastRunDate
Dim strLocalfile
Dim newfolder, newfolderpath
Dim strCurrentFolder


Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim WshShell:Set WshShell = WScript.CreateObject("WScript.Shell")
Dim WshEnv:Set WshEnv = WshShell.Environment("Process")
SysDrive = WshEnv("%SYSTEMDRIVE%")
SysRoot = WshEnv("SYSTEMROOT")
LogonSvr = WshEnv("LOGONSERVER")
strDsk = WshShell.SpecialFolders("Desktop")
strMyDocuments = WshShell.SpecialFolders("MyDocuments")

Const OverwriteExisting = True
'-------------------------------------------------------------------------------------------------------------------------
'Do not run on these machines (list of servers)
Set objNetwork = CreateObject("WScript.Network")
	thisComputer = objNetwork.ComputerName
	arrComputers = Array("Computer","Server","Server","Computer")
For Each arrayElement in arrComputers
	if arrayElement = thisComputer then
		wscript.Quit
	end if 
next
'----------------------------------------------------------------------------------------------------------------------------
'Check if this is a Server. If this is a server quit
'We don't want to delete any scheduled jobs on servers
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
	If InStr(1,objItem.Caption,"Server") Then Wscript.Quit
Next
'----------------------------------------------------------------------------------------------------------------------------
'Now Create a registry value so if this script has run it wont run again today
	varToday = Anyname
		varToday = Weekday(Date)

	Verify = "HKLM\SOFTWARE\MyInstallsAndFixes\" 

 'Check if scan has run today and if so exit
On Error Resume Next
	LastRunDate = WshShell.RegRead(Verify & "Cleanmgr")
If LastRunDate =  cstr(Date) Then
    WScript.Quit
Else 
    WshShell.RegWrite Verify & "AnyName",Date,"REG_SZ"
End If
On Error Goto 0
'----------------------------------------------------------------------------------------------------------------------------
'CreateNewFolder
	newfolderpath = strDsk & "\MyProgs"

If Not objFSO.FolderExists(newfolderpath) Then
	Set newfolder = objFSO.CreateFolder(newfolderpath)
End If
'----------------------------------------------------------------------------------------------------------------------------
'Now copy the encoded script file to users machine
	strLocalfile = strDsk & "\somefilename" 

If objFSO.FileExists(strLocalfile)=false Then
	objFSO.CopyFile  "\\Server\Share$\somefile.txt" , strDsk  , OverwriteExisting = true
end if
'----------------------------------------------------------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top