Option Explicit ' File ' $Id$ ' $DateTime$ ' $Change$ ' $File$ ' $Revision$ ' $Author$ ' Call GetInfo("C:\Program Files (x86)\SysInternals\accesschk.exe","") ' Call GetInfo("C:\Program Files (x86)\SysInternals\AccessEnum.exe","") ' WScript.quit Dim obj_Named_Args Dim str_ZipSrc , str_InstallDir , str_ShortcutDir Set obj_Named_Args = WScript.Arguments.Named ' WScript.Arguments is numerically indexed collection. Must be iterated using index from 0 to Arguments.Length-1 ' WScript.Arguments.UnNamed is a numerically indexed collection like Arguments. ' WScript.Arguments.Named is a key:value collection specified on command line like this "/key:value" str_ZipSrc = obj_Named_Args.Item("Zip") str_InstallDir = DirExists(obj_Named_Args.Item("InstallDir")) str_ShortcutDir = DirExists(obj_Named_Args.Item("ShortcutDir")) If Len(str_ZipSrc) AND Not IsEmpty(str_InstallDir) Then Call Unzip(str_ZipSrc,str_InstallDir) Else WScript.Echo "/Zip: and /InstallDir: Not specified." End If If Not IsEmpty(str_InstallDir) AND Not IsEmpty(str_ShortcutDir) Then ' Call CreateShortcut ( str_InstallDir , "AccessChk.exe" , str_ShortcutDir , "AccessChk" , "AccessChk is a command-line tool for viewing the effective permissions on files, registry keys, services, processes, kernel objects, and more." ) Call CreateShortcut ( str_InstallDir , "AccessEnum.exe" , str_ShortcutDir , "AccessEnum" , "This simple yet powerful security tool shows you who has what access to directories, files and Registry keys on your systems. Use it to find holes in your permissions." ) Call CreateShortcut ( str_InstallDir , "AdExplorer.exe" , str_ShortcutDir , "AdExplorer" , "Active Directory Explorer is an advanced Active Directory (AD) viewer and editor." ) Call CreateShortcut ( str_InstallDir , "AdInsight.exe" , str_ShortcutDir , "AdInsight" , "An LDAP (Light-weight Directory Access Protocol) real-time monitoring tool aimed at troubleshooting Active Directory client applications." ) ' Call CreateShortcut ( str_InstallDir , "AdRestore.exe" , str_ShortcutDir , "AdRestore" , "Undelete Server 2003 Active Directory objects." ) ' Call CreateShortcut ( str_InstallDir , "Autologon.exe" , str_ShortcutDir , "Autologon" , "Bypass password screen during logon." ) Call CreateShortcut ( str_InstallDir , "Autoruns.exe" , str_ShortcutDir , "Autoruns" , "See what programs are configured to startup automatically when your system boots and you login. Autoruns also shows you the full list of Registry and file locations where applications can configure auto-start settings." ) Call CreateShortcut ( str_InstallDir , "BgInfo.exe" , str_ShortcutDir , "BgInfo" , "This fully-configurable program automatically generates desktop backgrounds that include important information about the system including IP addresses, computer name, network adapters, and more." ) Call CreateShortcut ( str_InstallDir , "CacheSet.exe" , str_ShortcutDir , "CacheSet" , "CacheSet is a program that allows you to control the Cache Manager's working set size using functions provided by NT. It's compatible with all versions of NT." ) ' Call CreateShortcut ( str_InstallDir , "ClockRes.exe" , str_ShortcutDir , "ClockRes" , "View the resolution of the system clock, which is also the maximum timer resolution." ) ' Call CreateShortcut ( str_InstallDir , "Contig.exe" , str_ShortcutDir , "Contig" , "Wish you could quickly defragment your frequently used files? Use Contig to optimize individual files, or to create new files that are contiguous." ) ' Call CreateShortcut ( str_InstallDir , "Coreinfo.exe" , str_ShortcutDir , "Coreinfo" , "Coreinfo is a new command-line utility that shows you the mapping between logical processors and the physical processor, NUMA node, and socket on which they reside, as well as the cache’s assigned to each logical processor." ) ' Call CreateShortcut ( str_InstallDir , "Ctrl2cap.exe" , str_ShortcutDir , "Ctrl2cap" , "This is a kernel-mode driver that demonstrates keyboard input filtering just above the keyboard class driver in order to turn caps-locks into control keys. Filtering at this level allows conversion and hiding of keys before NT even 'sees' them. Ctrl2cap also shows how to use NtDisplayString() to print messages to the initialization blue-screen." ) Call CreateShortcut ( str_InstallDir , "DebugView.exe" , str_ShortcutDir , "DebugView" , "Another first from Sysinternals: This program intercepts calls made to DbgPrint by device drivers and OutputDebugString made by Win32 programs. It allows for viewing and recording of debug session output on your local machine or across the Internet without an active debugger." ) Call CreateShortcut ( str_InstallDir , "Desktops.exe" , str_ShortcutDir , "Desktops" , "This new utility enables you to create up to four virtual desktops and to use a tray interface or hotkeys to preview what’s on each desktop and easily switch between them." ) Call CreateShortcut ( str_InstallDir , "Disk2vhd.exe" , str_ShortcutDir , "Disk2vhd" , "Disk2vhd simplifies the migration of physical systems into virtual machines (p2v)." ) ' Call CreateShortcut ( str_InstallDir , "DiskExt.exe" , str_ShortcutDir , "DiskExt" , "Display volume disk-mappings." ) Call CreateShortcut ( str_InstallDir , "Diskmon.exe" , str_ShortcutDir , "Diskmon" , "This utility captures all hard disk activity or acts like a software disk activity light in your system tray." ) Call CreateShortcut ( str_InstallDir , "DiskView.exe" , str_ShortcutDir , "DiskView" , "Graphical disk sector utility." ) ' Call CreateShortcut ( str_InstallDir , "Disk Usage (DU).exe" , str_ShortcutDir , "Disk Usage (DU)" , "View disk usage by directory." ) ' Call CreateShortcut ( str_InstallDir , "EFSDump.exe" , str_ShortcutDir , "EFSDump" , "View information for encrypted files." ) ' FindLinks ' Call CreateShortcut ( str_InstallDir , "Handle.exe" , str_ShortcutDir , "Handle" , "This handy command-line utility will show you what files are open by which processes, and much more." ) ' Call CreateShortcut ( str_InstallDir , "Hex2dec.exe" , str_ShortcutDir , "Hex2dec" , "Convert hex numbers to decimal and vice versa." ) ' Call CreateShortcut ( str_InstallDir , "Junction.exe" , str_ShortcutDir , "Junction" , "Create Win2K NTFS symbolic links." ) ' Call CreateShortcut ( str_InstallDir , "LDMDump.exe" , str_ShortcutDir , "LDMDump" , "Dump the contents of the Logical Disk Manager's on-disk database, which describes the partitioning of Windows 2000 Dynamic disks." ) ' Call CreateShortcut ( str_InstallDir , "ListDLLs.exe" , str_ShortcutDir , "ListDLLs" , "List all the DLLs that are currently loaded, including where they are loaded and their version numbers. Version 2.0 prints the full path names of loaded modules." ) ' Call CreateShortcut ( str_InstallDir , "LiveKd.exe" , str_ShortcutDir , "LiveKd" , "Use Microsoft kernel debuggers to examine a live system." ) Call CreateShortcut ( str_InstallDir , "LoadOrder.exe" , str_ShortcutDir , "LoadOrder" , "See the order in which devices are loaded on your WinNT/2K system." ) ' Call CreateShortcut ( str_InstallDir , "LogonSessions.exe" , str_ShortcutDir , "LogonSessions" , "List the active logon sessions on a system." ) ' Call CreateShortcut ( str_InstallDir , "MoveFile.exe" , str_ShortcutDir , "MoveFile" , "Allows you to schedule move and delete commands for the next reboot." ) ' Call CreateShortcut ( str_InstallDir , "NTFSInfo.exe" , str_ShortcutDir , "NTFSInfo" , "Use NTFSInfo to see detailed information about NTFS volumes, including the size and location of the Master File Table (MFT) and MFT-zone, as well as the sizes of the NTFS meta-data files." ) Call CreateShortcut ( str_InstallDir , "PageDefrag.exe" , str_ShortcutDir , "PageDefrag" , "Defragment your paging files and Registry hives." ) ' Call CreateShortcut ( str_InstallDir , "PendMoves.exe" , str_ShortcutDir , "PendMoves" , "Enumerate the list of file rename and delete commands that will be executed the next boot." ) ' Call CreateShortcut ( str_InstallDir , "PipeList.exe" , str_ShortcutDir , "PipeList" , "Displays the named pipes on your system, including the number of maximum instances and active instances for each pipe." ) Call CreateShortcut ( str_InstallDir , "PortMon.exe" , str_ShortcutDir , "PortMon" , "Monitor serial and parallel port activity with this advanced monitoring tool. It knows about all standard serial and parallel IOCTLs and even shows you a portion of the data being sent and received. Version 3.x has powerful new UI enhancements and advanced filtering capabilities." ) ' Call CreateShortcut ( str_InstallDir , "ProcDump.exe" , str_ShortcutDir , "ProcDump" , "This new command-line utility is aimed at capturing process dumps of otherwise difficult to isolate and reproduce CPU spikes. It also serves as a general process dump creation utility and can also monitor and generate process dumps when a process has a hung window or unhandled exception." ) Call CreateShortcut ( str_InstallDir , "Process Explorer.exe" , str_ShortcutDir , "Process Explorer" , "Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more. This uniquely powerful utility will even show you who owns each process." ) Call CreateShortcut ( str_InstallDir , "Process Monitor.exe" , str_ShortcutDir , "Process Monitor" , "Monitor file system, Registry, process, thread and DLL activity in real-time." ) Call CreateShortcut ( str_InstallDir , "ProcFeatures.exe" , str_ShortcutDir , "ProcFeatures" , "This applet reports processor and Windows support for Physical Address Extensions and No Execute buffer overflow protection." ) ' Call CreateShortcut ( str_InstallDir , "PsExec.exe" , str_ShortcutDir , "PsExec" , "Execute processes on remote systems." ) ' Call CreateShortcut ( str_InstallDir , "PsFile.exe" , str_ShortcutDir , "PsFile" , "See what files are opened remotely." ) ' Call CreateShortcut ( str_InstallDir , "PsGetSid.exe" , str_ShortcutDir , "PsGetSid" , "Displays the SID of a computer or a user." ) ' Call CreateShortcut ( str_InstallDir , "PsInfo.exe" , str_ShortcutDir , "PsInfo" , "Obtain information about a system." ) ' Call CreateShortcut ( str_InstallDir , "PsKill.exe" , str_ShortcutDir , "PsKill" , "Terminate local or remote processes." ) ' Call CreateShortcut ( str_InstallDir , "PsList.exe" , str_ShortcutDir , "PsList" , "Show information about processes and threads." ) ' Call CreateShortcut ( str_InstallDir , "PsLoggedOn.exe" , str_ShortcutDir , "PsLoggedOn" , "Show users logged on to a system." ) ' Call CreateShortcut ( str_InstallDir , "PsLogList.exe" , str_ShortcutDir , "PsLogList" , "Dump event log records." ) ' Call CreateShortcut ( str_InstallDir , "PsPasswd.exe" , str_ShortcutDir , "PsPasswd" , "Changes account passwords." ) ' Call CreateShortcut ( str_InstallDir , "PsService.exe" , str_ShortcutDir , "PsService" , "View and control services." ) ' Call CreateShortcut ( str_InstallDir , "PsShutdown.exe" , str_ShortcutDir , "PsShutdown" , "Shuts down and optionally reboots a computer." ) ' Call CreateShortcut ( str_InstallDir , "PsSuspend.exe" , str_ShortcutDir , "PsSuspend" , "Suspend and resume processes." ) Call CreateShortcut ( str_InstallDir , "RAMMap.exe" , str_ShortcutDir , "RAMMap" , "An advanced physical memory usage analysis utility that presents usage information in different ways on its several different tabs." ) ' Call CreateShortcut ( str_InstallDir , "RegDelNull.exe" , str_ShortcutDir , "RegDelNull" , "Scan for and delete Registry keys that contain embedded null-characters that are otherwise undeleteable by standard Registry-editing tools." ) ' Call CreateShortcut ( str_InstallDir , "RegJump.exe" , str_ShortcutDir , "RegJump" , "Jump to the registry path you specify in Regedit." ) Call CreateShortcut ( str_InstallDir , "RootkitRevealer.exe" , str_ShortcutDir , "RootkitRevealer" , "Scan your system for rootkit-based malware." ) ' Call CreateShortcut ( str_InstallDir , "SDelete.exe" , str_ShortcutDir , "SDelete" , "Securely overwrite your sensitive files and cleanse your free space of previously deleted files using this DoD-compliant secure delete program." ) Call CreateShortcut ( str_InstallDir , "ShareEnum.exe" , str_ShortcutDir , "ShareEnum" , "Scan file shares on your network and view their security settings to close security holes." ) Call CreateShortcut ( str_InstallDir , "ShellRunas.exe" , str_ShortcutDir , "ShellRunas" , "Launch programs as a different user via a convenient shell context-menu entry." ) ' Call CreateShortcut ( str_InstallDir , "Sigcheck.exe" , str_ShortcutDir , "Sigcheck" , "Dump file version information and verify that images on your system are digitally signed." ) ' Call CreateShortcut ( str_InstallDir , "Streams.exe" , str_ShortcutDir , "Streams" , "Reveal NTFS alternate streams." ) ' Call CreateShortcut ( str_InstallDir , "Strings.exe" , str_ShortcutDir , "Strings" , "Search for ANSI and UNICODE strings in binaryimages." ) ' Call CreateShortcut ( str_InstallDir , "Sync.exe" , str_ShortcutDir , "Sync" , "Flush cached data to disk." ) Call CreateShortcut ( str_InstallDir , "TCPView.exe" , str_ShortcutDir , "TCPView" , "Active socket command-line viewer." ) Call CreateShortcut ( str_InstallDir , "VMMap.exe" , str_ShortcutDir , "VMMap" , "VMMap is a process virtual and physical memory analysis utility." ) ' Call CreateShortcut ( str_InstallDir , "VolumeId.exe" , str_ShortcutDir , "VolumeId" , "Set Volume ID of FAT or NTFS drives." ) ' Call CreateShortcut ( str_InstallDir , "Whois.exe" , str_ShortcutDir , "Whois" , "See who owns an Internet address." ) Call CreateShortcut ( str_InstallDir , "WinObj.exe" , str_ShortcutDir , "WinObj" , "The ultimate Object Manager namespace viewer is here." ) Call CreateShortcut ( str_InstallDir , "ZoomIt.exe" , str_ShortcutDir , "ZoomIt" , "Presentation utility for zooming and drawing on the screen." ) Call CreateShortcut ( str_InstallDir , "ADInsight.chm",str_ShortcutDir , "ADInsight Help" , "" ) Call CreateShortcut ( str_InstallDir , "autoruns.chm",str_ShortcutDir , "autoruns Help" , "" ) Call CreateShortcut ( str_InstallDir , "dbgview.chm",str_ShortcutDir , "dbgview Help" , "" ) Call CreateShortcut ( str_InstallDir , "Disk2vhd.chm",str_ShortcutDir , "Disk2vhd Help" , "" ) Call CreateShortcut ( str_InstallDir , "procexp.chm",str_ShortcutDir , "procexp Help" , "" ) Call CreateShortcut ( str_InstallDir , "procmon.chm",str_ShortcutDir , "procmon Help" , "" ) Call CreateShortcut ( str_InstallDir , "Pstools.chm",str_ShortcutDir , "Pstools Help" , "" ) Call CreateShortcut ( str_InstallDir , "RootkitRevealer.chm",str_ShortcutDir , "RootkitRevealer Help" , "" ) Call CreateShortcut ( str_InstallDir , "tcpview.chm",str_ShortcutDir , "tcpview Help" , "" ) Call CreateShortcut ( str_InstallDir , "Vmmap.chm",str_ShortcutDir , "Vmmap Help" , "" ) Call CreateShortcut ( str_InstallDir , "DISKMON.HLP",str_ShortcutDir , "DISKMON Help" , "" ) Call CreateShortcut ( str_InstallDir , "pagedfrg.hlp",str_ShortcutDir , "pagedfrg Help" , "" ) Call CreateShortcut ( str_InstallDir , "PORTMON.HLP",str_ShortcutDir , "PORTMON Help" , "" ) Call CreateShortcut ( str_InstallDir , "TCPVIEW.HLP",str_ShortcutDir , "TCPVIEW Help" , "" ) Call CreateShortcut ( str_InstallDir , "WINOBJ.HLP",str_ShortcutDir , "WINOBJ Help" , "" ) Call CreateShortcut ( str_InstallDir , "AdExplorer.chm",str_ShortcutDir , "AdExplorer Help" , "" ) Else WScript.Echo "/InstallDir: AND /ShortcutDir: Not specified." End If WScript.Quit ' ***************************************************************************** ' ***************************************************************************** ' If file or directory exists, return fully qualified path to it. ' If it doesn't exist, return blank string Function FileExists(str_Fname) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(str_Fname)) Then FileExists = fso.GetAbsolutePathName(str_Fname) Else FileExists = Empty End If Set fso = Nothing End Function Function DirExists(str_DirName) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FolderExists(str_DirName)) Then DirExists = fso.GetFolder(str_DirName) Else DirExists = Empty End If Set fso = Nothing End Function ' ***************************************************************************** ' From http://www.robvanderwoude.com/vbstech_files_zip.php#CopyHereUNZIP Sub Extract( ByVal myZipFile, ByVal myTargetDir ) ' Function to extract all files from a compressed "folder" ' (ZIP, CAB, etc.) using the Shell Folders' CopyHere method ' (http://msdn2.microsoft.com/en-us/library/ms723207.aspx). ' All files and folders will be extracted from the ZIP file. ' A progress bar will be displayed, and the user will be ' prompted to confirm file overwrites if necessary. ' ' Note: ' This function can also be used to copy "normal" folders, ' if a progress bar and confirmation dialog(s) are required: ' just use a folder path for the "myZipFile" argument. ' ' Arguments: ' myZipFile [string] the fully qualified path of the ZIP file ' myTargetDir [string] the fully qualified path of the (existing) destination folder ' ' Based on an article by Gerald Gibson Jr.: ' http://www.codeproject.com/csharp/decompresswinshellapics.asp ' ' Written by Rob van der Woude ' http://www.robvanderwoude.com Dim intOptions, objShell, objSource, objTarget ' Create the required Shell objects Set objShell = CreateObject( "Shell.Application" ) ' Create a reference to the files and folders in the ZIP file Set objSource = objShell.NameSpace( myZipFile ).Items( ) ' Create a reference to the target folder Set objTarget = objShell.NameSpace( myTargetDir ) ' These are the available CopyHere options, according to MSDN ' (http://msdn2.microsoft.com/en-us/library/ms723207.aspx). ' On my test systems, however, the options were completely ignored. ' 4: Do not display a progress dialog box. ' 8: Give the file a new name in a move, copy, or rename ' operation if a file with the target name already exists. ' 16: Click "Yes to All" in any dialog box that is displayed. ' 64: Preserve undo information, if possible. ' 128: Perform the operation on files only if a wildcard file ' name (*.*) is specified. ' 256: Display a progress dialog box but do not show the file ' names. ' 512: Do not confirm the creation of a new directory if the ' operation requires one to be created. ' 1024: Do not display a user interface if an error occurs. ' 4096: Only operate in the local directory. ' Don't operate recursively into subdirectories. ' 8192: Do not copy connected files as a group. ' Only copy the specified files. intOptions = 256 ' UnZIP the files objTarget.CopyHere objSource, intOptions ' Release the objects Set objSource = Nothing Set objTarget = Nothing Set objShell = Nothing End Sub ' ***************************************************************************** ' Source Dir ' Source Executable file name ' Link Dir ' Link name ' Description Sub CreateShortcut(str_SrcDir , str_SrcFname , str_LinkDir , str_LinkName , str_LinkDescr ) Dim str_Src , str_Link ' Need to make sure the source file exists. If Right(str_SrcDir,1) = "\" Then str_Src = FileExists(str_SrcDir & str_SrcFname) Else str_Src = FileExists(str_SrcDir & "\" & str_SrcFname) End If If IsEmpty(str_Link) Then WScript.Echo "Destination File '" & str_Link & "' not found. Bail!" Exit Sub End If If Right(str_LinkDir,1) = "\" Then str_Link = str_LinkDir & str_LinkName Else str_Link = str_LinkDir & "\" & str_LinkName Dim WshShell , oShellLink set WshShell = WScript.CreateObject("WScript.Shell") ' FullName ' TargetPath path to executable ' WindowStyle ' WorkingDirectory Directory in which the shortcut starts. ' IconLocation A string that locates the icon. Should contain a fully qualified path and an index. ' 1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. ' 3 Activates the window and displays it as a maximized window. ' 7 Minimizes the window and activates the next top-level window. set oShellLink = WshShell.CreateShortcut(str_Link & ".lnk") oShellLink.TargetPath = str_Src oShellLink.WindowStyle = 1 oShellLink.IconLocation = str_Src & ", 0" oShellLink.Description = str_LinkDescr oShellLink.WorkingDirectory = str_SrcDir oShellLink.Save End Sub ' ***************************************************************************** CONST wbemFlagForwardOnly = 32 ' (0x20) Causes a forward-only enumerator to be returned. Forward-only enumerators are generally much faster and use less memory than conventional enumerators, but they do not allow calls to SWbemObject.Clone_. CONST wbemFlagBidirectional = 0 ' (0x0) Causes WMI to retain pointers to objects of the enumeration until the client releases the enumerator. CONST wbemFlagReturnImmediately = 16 ' (0x10) Causes the call to return immediately. CONST wbemFlagReturnWhenComplete = 0 ' (0x0) Causes this call to block until the query is complete. This flag calls the method in the synchronous mode. CONST wbemQueryFlagPrototype = 2 ' (0x2) Used for prototyping. It stops the query from happening and returns an object that looks like a typical result object. CONST wbemFlagUseAmendedQualifiers = 131072 ' (0x20000) Causes WMI to return class amendment data with the base class definition. For more information, see Localizing WMI Class Information. Sub GetInfo(str_FName,str_DosName) Dim str_Computer str_Computer = "." Dim str_Drive , str_Path , str_FileName , str_Extension ' "C:\Program Files (x86)\SysInternals\accesschk.exe" str_Drive="C:" : str_Path="\Program Files (x86)\SysInternals\" : str_FileName="accesschk" : str_Extension=".exe" Dim str_Query Dim objWMIService Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & str_Computer & "\root\cimv2") ' CIM_DataFile : CIM_LogicalFile : CIM_LogicalElement : CIM_ManagedSystemElement ' Query: ' Drive Drive letter (including the colon that follows the drive letter) of the file:: "C:" ' Path Path of the file including the leading and trailing backslashes:: "\windows\system\" ' FileName File name without the file name extension:: "MyDataFile" ' Extension File name extension without the preceding period (dot):: "txt", "mof", "mdb" ' ??? or ??? ' Name Full path name:: "c:\winnt\system\win.ini" ' ??? or ??? ' EightDotThreeFileName DOS-compatible file name:: "c:\progra~1" str_Query = "Select * From Cim_DataFile " _ & "Where (" & _ "Drive ='" & str_Drive & "' AND Path='" & str_Path & "' AND FileName='" & str_FileName & "' AND Extension='" & str_Extension & "'" & _ ")" ' ") OR (" & _ ' "Name ='" & str_FName & "'" & _ ' ") OR (" & _ ' "EightDotThreeFileName ='" & str_DosName & "'" & _ Wscript.echo "query={" & str_Query & "}" Dim colItems , objItem Set colItems = objWMIService.ExecQuery(str_Query,"WQL",wbemFlagReturnWhenComplete) WScript.Echo "typename of colItems=" & typename(colItems) WScript.Echo "isObject(colItems)=" & isObject(colItems) WScript.Echo "isEmpty(colItems)=" & isEmpty(colItems) WScript.Echo "isNull(colItems)=" & isNull(colItems) WScript.Echo "olItems.Count=" & colItems.Count For Each objItem In colItems Wscript.Echo "-----------------------------------" Wscript.Echo "CIM_DataFile instance" Wscript.Echo "-----------------------------------" Wscript.Echo "FileName: " & objItem.Name WScript.Echo "FileSize (bytes): " & objItem.FileSize Next End Sub