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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to install BGinfo 1

Status
Not open for further replies.

Dudbolt

IS-IT--Management
Nov 28, 2002
19
GB
I have hunted for a script that would help me install and run sysinternals bginfo on my users workstations and my servers. I was trying a simple batch file that copies the files to a local folder and places a link in the startup folder. No success so far. Can anyone point me in the right direction so something more suitable. i would like to be able to make the changes to one file on the server and then propogate that to all users. I was hoping to look to active directory for a solution.

cheers

garrett
 
Try the attached script. You will, of course, need to modify it if the users don't have privileges to write to c:\program files.

Code:
On Error Resume Next

'Setup objects
Dim oWSH: Set oWSH = WScript.CreateObject("WScript.Shell")
Dim oFSO: Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Dim oWSHL

'Find the Start Menu startup folder
Dim startup: startup = oWSH.SpecialFolders("Startup")        

'-Either- Find the start location of the script (if run from server)
Dim source: source = Replace(WScript.ScriptFullName,"\" & WScript.ScriptName,"")                               

'-OR- Hardcode the path of the source (if run from local machine)
'Dim source: source = "\\server\share\folder"

'Find the program files folder then append the install folder
Dim target: target = oWSH.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir") & "\BGInfo"

Dim copyExe, copyBgi

'Create Target Folder
If CreateFolder(target) Then
                                                              
	'Copy Files
	oFSO.CopyFile source & "\bginfo.exe", target & "\bginfo.exe", True
	oFSO.CopyFile source & "\bginfo.bgi", target & "\bginfo.bgi", True
	
	If oFSO.FileExist(source & "\bginfo.exe") AND oFSO.FileExist(source & "\bginfo.bgi") Then
		'Create shortcut
		Set oWSHL = oWSH.CreateShortcut(startup & "\Run BGInfo.lnk")
		With oWSHL
			.TargetPath = target & "\bginfo.exe"
			.Arguments = Chr(34) & target & "\bginfo.bgi" & Chr(34) & " /timer:0"
			.IconLocation = target & "\bginfo.exe, 0"
			.Description = "Runs Background Info from SysInternals"
			.WorkingDirectory = target
			.Save
		End With
		Set oWSHL = Nothing
	Else
		'MsgBox "Failed to copy  a file" & vbcrlf & vbcrlf & err.description
	End If
Else
	'MsgBox "Failed to create folder: " & target & vbcrlf & vbcrlf & err.description
End If
                        
'Clean up                        
Set oWSH = Nothing
Set oFSO = Nothing
MsgBox "Done"
WScript.Quit

Function CreateFolder(folderName)

	On Error Resume Next            
            
	Dim aFolders: aFolders = Split(folderName,"\")
	Dim i
	Dim currentFolder
	
	For i = LBound(aFolders) to UBound(aFolders)
		currentFolder = currentFolder & aFolders(i) & "\"
		If NOT oFSO.FolderExists(currentFolder) Then
			oFSO.CreateFolder(currentFolder)
		End If
	Next  'i            
	
	If oFSO.FolderExists(folderName) Then
		CreateFolder = True
	Else
		CreateFolder = False
	End If
	
End Function

HtH,

Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top