' *********************************************** ' Initialization script for Win2K client ' Written by Linus Walleij ' Covered by GNU GPL version 2 or higher ' Tested on Windows Me and Windows 2000 ' *********************************************** Option Explicit ' *********************************************** ' Configuration options, configurate the script ' right HERE. Nowhere else... ' *********************************************** ' Printer configuration ' Set this to true to add printers... Const bAddPrinters = False ' Expand array to fit in printers. Dim aPrinters(1) aPrinters(1) = "\\printserver\myprinter" 'aPrinters(2) = "\\printserver\foo" 'aPrinters(3) = "\\printserver\foo" 'aPrinters(4) = "\\printserver\foo" Const strDefaultPrinter = "\\printserver\myprinter" ' *********************************************** ' Functions used herein... ' *********************************************** ' This holds LPT ports (bit old fashioned) Dim intCntPrinters intCntPrinters = 1 ' Generic function for adding a printer Function AddPrinter(strRemote) On Error Resume Next WSHNetwork.AddWindowsPrinterConnection strRemote, True If Err.Number Then WScript.Echo "Could not mount printer " & strRemote & "." & vbCRLF & "already mapped or unavailable." Err.Clear Else 'Also mount it for DOS... Well. WSHNetwork.AddPrinterConnection "LPT" & intCntPrinters & ":", strRemote, True intCntPrinters = intCntPrinters+1 ' Just ignore errors here If Err.Number Then Err.Clear End If End Function ' *********************************************** ' Create some very basic objects and Paths etc ' *********************************************** Dim WSHShell, WSHNetwork, WSHSystemEnvironment, FS Dim DesktopPath, SendToPath, StartMenuPath, QuickLaunchPath, MyDocumentsPath, SystemRootPath Set WSHShell = CreateObject("WScript.Shell") Set WSHNetwork = CreateObject("WScript.Network") Set WSHSystemEnvironment = WshShell.Environment("System") Set FS = CreateObject("Scripting.FileSystemObject") DesktopPath = WSHShell.SpecialFolders("Desktop") SendToPath = WSHShell.SpecialFolders("SendTo") StartMenuPath = WSHShell.SpecialFolders("StartMenu") MyDocumentsPath = WSHShell.SpecialFolders("MyDocuments") ' This is an ugly fix but it works, no other way I know of... QuickLaunchPath = SendToPath & "\..\Application Data\Microsoft\Internet Explorer\Quick Launch" ' Try environment and specials first, then fallback on defaults SystemRootPath = WSHShell.ExpandEnvironmentStrings("%SystemRoot%") If SystemRootPath = "%SystemRoot%" Then SystemRootPath = "" SystemRootPath = FS.GetSpecialFolder(0) End If If SystemRootPath="" Then If FS.FolderExists("C:\Windows") Then SystemRootPath = "C:\Windows" Else If FS.FolderExists("C:\WINNT") Then SystemRootPath = "C:\WINNT" End If If SystemRootPath = "" Then Wscript.Echo "Unable to locate Windows Directory!" WScript.Quit() End If End If End If ' This is used when creating custom shortcuts Dim MyShortcut ' Loop variable Dim i ' Test and comment out here ' WScript.Quit() ' ********************************************** ' Add our printers ' ********************************************** If bAddPrinters Then For i=1 To Ubound(aPrinters) AddPrinter aPrinters(i) Next ' Setting default Windows printer On Error Resume Next WSHNetwork.SetDefaultPrinter strDefaultPrinter If Err.Number Then WScript.Echo "Could not set default printer." Err.Clear End If End If ' ********************************************** ' Remove Outlook Express from Quick Launch Bar, ' Add Outlook instead if it exists. ' ********************************************** ' Remove shortcut to Outlook Express if it exists If FS.FileExists(QuickLaunchPath & "\Launch Outlook Express.lnk") Then FS.DeleteFile(QuickLaunchPath & "\Launch Outlook Express.lnk") End If ' Instead add a shortcut to Outlook (standard) If FS.FileExists("C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE") Then Set MyShortcut = WSHShell.CreateShortcut(QuickLaunchPath & "\Outlook.lnk") MyShortcut.TargetPath = "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE" MyShortcut.WorkingDirectory = "C:\Program Files\Microsoft Office\Office" MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE, 0" MyShortcut.Save End If ' ********************************************** ' Add a shortcut to file exploder on Desktop, ' Quick Launch and in the Start Menu ' ********************************************** Dim ExplorerPath, ExplorerIconPath If FS.FileExists(SystemRootPath & "\explorer.scf") Then ExplorerPath = SystemRootPath & "\explorer.scf" ExplorerIconPath = ExplorerPath & ", 0" Else ExplorerPath = SystemRootPath & "\explorer.exe" ExplorerIconPath = ExplorerPath & ", 1" End If Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\Windows Explorer.lnk") MyShortcut.TargetPath = ExplorerPath MyShortcut.WorkingDirectory = SystemRootPath MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = ExplorerIconPath MyShortcut.Save Set MyShortcut = WSHShell.CreateShortcut(QuickLaunchPath & "\Windows Explorer.lnk") MyShortcut.TargetPath = ExplorerPath MyShortcut.WorkingDirectory = SystemRootPath MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = ExplorerIconPath MyShortcut.Save Set MyShortcut = WSHShell.CreateShortcut(StartMenuPath & "\Windows Explorer.lnk") MyShortcut.TargetPath = ExplorerPath MyShortcut.WorkingDirectory = SystemRootPath MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = ExplorerIconPath MyShortcut.Save ' ********************************************** ' Add a shortcut to Command Line Prompt in ' Start Menu ' ********************************************** Dim CmdPromptPath, CmdIconPath If FS.FileExists(SystemRootPath & "\System32\cmd.exe") Then CmdPromptPath = SystemRootPath & "\System32\cmd.exe" CmdIconPath = CmdPromptPath & ", 0" Else CmdPromptPath = SystemRootPath & "\command.com" CmdIconPath = SystemRootPath & "\SYSTEM\PIFMGR.DLL, 0" End If Set MyShortcut = WSHShell.CreateShortcut(StartMenuPath & "\Command Line.lnk") MyShortcut.TargetPath = CmdPromptPath MyShortcut.WorkingDirectory = SystemRootPath MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = CmdIconPath MyShortcut.Save ' ********************************************** ' Add "command prompt here" in the Right Click ' menu, aka the "Win 95 powertoy"... ' ********************************************** WSHShell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\DosHere\", "Command &Prompt Here", "REG_SZ" WSHShell.RegWrite "HKEY_CLASSES_ROOT\Folder\shell\DosHere\command\", CmdPromptPath, "REG_SZ" ' ********************************************** ' Add a shortcut to Notepad in "SendTo" ' ********************************************** Set MyShortcut = WSHShell.CreateShortcut(SendToPath & "\Notepad.lnk") MyShortcut.TargetPath = SystemRootPath & "\notepad.exe" MyShortcut.WorkingDirectory = SystemRootPath MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = SystemRootPath & "\notepad.exe, 0" MyShortcut.Save ' **************************************************** ' Add privacy improvement script... What do I know. ' **************************************************** Dim ZapFile On Error Resume Next Set ZapFile = FS.CreateTextFile(MyDocumentsPath & "\zapfiles.vbs") If Not Err.Number Then ZapFile.WriteLine "dim oFileSys, WSHShell, oFolder, oFiles, strFile, item2, RecentPath" ZapFile.WriteLine "Set oFileSys = CreateObject(""Scripting.FileSystemObject"")" ZapFile.WriteLine "Set WSHShell = CreateObject(""WScript.Shell"")" ZapFile.WriteLine "RecentPath = WSHShell.SpecialFolders(""Recent"")" ZapFile.WriteLine "Set oFolder=oFileSys.GetFolder(RecentPath)" ZapFile.WriteLine "Set oFiles=oFolder.Files" ZapFile.WriteLine "item2=0" ZapFile.WriteLine "For each item2 in oFiles" ZapFile.WriteLine "strFile = RecentPath & ""\"" & item2.Name" ZapFile.WriteLine "oFileSys.DeleteFile strFile, True" ZapFile.WriteLine "Next" ZapFile.Close ' Make it autorun... WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", MyDocumentsPath & "\zapfiles.vbs", "REG_EXPAND_SZ" Else Err.Clear End If ' **************************************************** ' If EMACS is installed, add a shortcut in "SendTo" ' and the Quick Launch Bar ' **************************************************** Dim EMACSdir EMACSdir = WSHShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs\emacs_dir") If (EMACSdir <> "") Then 'WScript.Echo "EMACS Installed at: " & EMACSdir Set MyShortcut = WSHShell.CreateShortcut(SendToPath & "\EMACS.lnk") MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings(EMACSdir & "\bin\runemacs.exe") MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(EMACSdir & "\bin") MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings(EMACSdir & "\bin\runemacs.exe, 0") MyShortcut.Save Set MyShortcut = WSHShell.CreateShortcut(QuickLaunchPath & "\EMACS.lnk") MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings(EMACSdir & "\bin\runemacs.exe") MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(EMACSdir & "\bin") MyShortcut.WindowStyle = 4 MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings(EMACSdir & "\bin\runemacs.exe, 0") MyShortcut.Save Else Wscript.Echo "Consider installing EMACS!" End If