Search This Blog

Monday, July 7, 2008

TrainSignal Training Screwup.

My company recently purchased a $19,000 complete training set from TrainSignal with a full site license.

While the material is good, it only works when launched from a locally attached drive or local copy.

If you try to run the software from a UNC path \\server\trainsignal all items give an error.

Turned out that they were using a file called proxy.exe made by northwind renamed to whatever the media html file that needed to be executed. Under each media cd folder there was an fscommand folder with batch files and exe files of the same name(exe files were renamed proxy.exe files). The batch files contained the following command:

start ../4b/4b.html

Batch files cannot be executed properly from unc paths as they assume c:\windows as the working folder. So instead of launching \\server\share\4b\4b.html it executes c:\4b\4b.html which does not exist.

Some of the material used ftoolapp.exe to launch things with the same result.

This is all due to using Flash based menus instead of something that actually works properly outside of the browser world.

We were also able to integrate this into IIS by creating a link to the UNC path. Making a virtual directory will not help as when the menu.exe files are executed in IE, they execute from %username%\temporary internet files instead of the intended location.

Lesson to be learned: write your application for the intended platform to be used. Not just make it look nice using Flash. Testing different scenarios is not a bad idea either.

The script has a few different functions:

/change

runs through all subfolders of the execution location, so you would place the exe into the root of all the training material. Renames the existing .exe files that have a corresponding .bat name to .old

Also finds any ftoolapp.exe files, renames them to .old and makes a copy of itself instead.

/undo

Performs the same function as /change, except backwards. Deletes the new .exe files and renames the .old files to .exe

no switch

This is the intended mode for the batch file problem.

Checks its own name and finds the corresponding batch file. Reads the contents of the batch file and strips start ../ from the command. Executes the command as stated using the current unc or local path.

filename.xxx as a switch

This switch was made after i discovered another problem with some of the newer training material. It was launched using ftoolapp.exe filename.xxx, which exhibited the same problem with UNC.

If the operating system is Vista, checks for the presense of the TechSmith codec in the registry and checks the file extension for .wmv or .avi and Starts Windows Media Player %programfiles%\Windows Media Player\wmplayer.exe with the corresponding media file name. Other extensions launch using the associated application.

If the OS is Windows XP, executes whatever the associated media player file is.

I ran into problems on Vista trying to launch associated WMP files, WMP comes up empty and does not play. XP did not exhibit this problem.

Please dont use the old script i posted earlier. I found yet another glitch that needed changing. Here is the new one.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=UltraProxy.ico
#AutoIt3Wrapper_outfile=UltraProxy.exe
#AutoIt3Wrapper_compression=4
#AutoIt3Wrapper_useansi=y
#AutoIt3Wrapper_run_tidy=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
	;	----------------------------------------------------------------------------
	;	Functions:
	;		No switch execution
	;			This is the intended use of the script.
	;			Checks its own name and finds a corresponding batch file.
	;			Reads the contents of the batch file and strips “start ../” from the command.
	;			Executes the command without using the Windows command interpreter.
	;		filename.xxx
	;			This mode will start a Windows Media file that is specified.
	;
	;		/change
	;			Will check current folder and all subfolders for presence of batch files.
	;			If a batch file is found and it is not autorun.bat, the corresponding .exe file will be renamed to .old and the script will make a copy of itself in place of the .exe file.
	;
	;		/undo
	;			Will check the current folder and all subfolders for the presence of batch files.
	;			If a batch file is found and it has a corresponding .old file, the .exe will be deleted and the .old renamed to .exe.
	;
	;	----------------------------------------------------------------------------
	;	This script was made with a specific purpose of replacing the proxy.exe files used by TrainSignal training material
	;	The renamed proxy.exe files would launch name.bat files which would not work over a UNC path.(\\blah\...)
	;	This script will check it's name at startup, check the corresponding .bat file for the content,
	;	strip the bat command and use the left over command to do a clean launch. Example: "start ../intro/intro.html will become \\ProperUNCPath/intro/intro.html
	;	It is written with the specific spacing used in the TrainSignal application. Do not use it for anything else.
	;
	;	Feel free to modify at will.
	;	Alex Belenkiy © ab@nyitsupport.com
	;	07/07/2008
	;
	;	RecursiveFileSearch function was modified from http://www.autoitscript.com/forum/index.php?showtopic=58558&st=0
#ce

AutoItSetOption("TrayIconHide", 1)
AutoItSetOption("WinTitleMatchMode", 2)

#include <array.au3>

If $CmdLine[0] = 0 Then
	Call("UltraProxy")
Else
	Select
		Case $CmdLine[1] = "/undo"
			$Undo = "1"
			Call("Change")
			
		Case $CmdLine[1] = "/change"
			$Undo = "0"
			Call("Change")
			
		Case Else
			Call("ftoolapp")
	EndSelect
EndIf

Func ftoolapp()
	If @OSVersion = "WIN_VISTA" Then
		If StringRight($CmdLineRaw, 4) = ".wmv" Or StringRight($CmdLineRaw, 4) = ".avi" Then
			If FileExists(@ScriptDir & "\Codec") Then
				$TSCC = RegEnumKey("HKEY_CURRENT_USER\Software\TechSmith", 1)
				If @error Then ShellExecuteWait(@ScriptDir & "\Codec\tscc.exe")
			EndIf
			ShellExecute(@ProgramFilesDir & "\Windows Media Player\wmplayer.exe", StringReplace(@ScriptDir & "\" & $CmdLineRaw, "/", "\", 0, 0))
		Else
			ShellExecute(StringReplace($CmdLineRaw, "/", "\", 0, 0), "", @ScriptDir)
		EndIf
	Else
		ShellExecute(StringReplace($CmdLineRaw, "/", "\", 0, 0), "", @ScriptDir)
	EndIf
EndFunc   ;==>ftoolapp

Func UltraProxy()
	$SP = StringTrimRight(@ScriptName, 4) & ".bat" ; Get launched name
	$BatchFile = FileOpen($SP, 0) ; Open corresponding batch file
	If $BatchFile = -1 Then Exit
	$SPL = FileReadLine($BatchFile, 1) ; Read the batch file command, first line only
	$new = StringReplace(StringTrimRight(@ScriptDir, 9) & StringTrimLeft($SPL, 9), "/", "\", 0, 0) ; trim off fscommand from the \\ProperUNCPath\ and 'start ../ from the batch command
	If @OSVersion = "WIN_VISTA" Then
		If StringRight($new, 4) = ".wmv" Or StringRight($new, 3) = ".avi" Then
			If FileExists(@ScriptDir & "\Codec") Then
				$TSCC = RegEnumKey("HKEY_CURRENT_USER\Software\TechSmith", 1)
				If @error Then ShellExecuteWait(@ScriptDir & "\Codec\tscc.exe")
			EndIf
			ShellExecute(@ProgramFilesDir & "\Windows Media Player\wmplayer.exe", $new)
		Else
			ShellExecute($new, "", @ScriptDir)
		EndIf
	Else
		Run(@ComSpec & " /c Start " & StringReplace($new, "/", "\", 0, 0), @ScriptDir, @SW_HIDE) ; Change all / to \ and run the necessary file.
	EndIf
EndFunc   ;==>UltraProxy

Func Change()
	MsgBox(64, "UltraProxy", "Converting Files. May take a few minutes." & @CRLF & @CRLF & "You will be notified upon completion" & @CRLF & @CRLF & "Please Wait...", 5)
	
	Dim $RFSarray[10240]
	Dim $Increment
	$Increment = 0
	$Array = RecursiveFileSearch(@ScriptDir)
	For $a = 1 To $Array[0]
		$ExeFile = StringTrimRight($Array[$a], 4) ;File name without extension
		Select
			Case $Undo = "0"
				;if $ExeFile = "ftoolapp" then

				If Not FileExists($ExeFile & ".old") Then
					If StringRight($ExeFile, 7) = "autorun" Then
						;do nothing
					Else
						FileMove($ExeFile & ".exe", $ExeFile & ".old")
						FileCopy(@AutoItExe, $ExeFile & ".exe")
						$Increment += 1
					EndIf
				EndIf
			Case $Undo = "1"
				If FileExists($ExeFile & ".old") Then
					FileDelete($ExeFile & ".exe")
					FileMove($ExeFile & ".old", $ExeFile & ".exe")
					$Increment += 1
				EndIf
		EndSelect
	Next
	MsgBox(64, "UltraProxy", "Finished." & @CRLF & @CRLF & $Increment & " out of " & $Array[0] & " files were processed.", 10)
EndFunc   ;==>Change

Func RecursiveFileSearch($startDir, $depth = 0)
	If $depth = 0 Then Global $RFSarray[1]
	$search = FileFindFirstFile($startDir & "\*.*")
	If @error Then Return
	;Search through all files and folders in directory
	While 1
		$next = FileFindNextFile($search)
		If @error Then ExitLoop
		;If folder, recurse
		If StringInStr(FileGetAttrib($startDir & "\" & $next), "D") Then
			RecursiveFileSearch($startDir & "\" & $next, $depth + 1)
		Else
			If StringInStr($startDir & "\" & $next, ".bat") Then
				_ArrayAdd($RFSarray, $startDir & "\" & $next)
				$RFSarray[0] += 1
			ElseIf StringInStr($startDir & "\" & $next, "ftoolapp.exe") Then
				_ArrayAdd($RFSarray, $startDir & "\" & $next)
				$RFSarray[0] += 1
			EndIf

		EndIf
	WEnd
	FileClose($search)
	If $depth = 0 Then Return $RFSarray
EndFunc   ;==>RecursiveFileSearch

Friday, June 20, 2008

CompRename - Yet another computer rename script

Use this script to rename computers from a any location in the domain. As long as domain admin credentials are supplied. 


The script uses a CompRename.csv file for old,new machine names.
So comp001,nyccomp001 would change comp001 to nycomp001.
Process as many computers at a time as necessary.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=CompRename.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
 
 AutoIt Version: 3.2.12.1
 Author:         Alex Belenkiy / Michael Viscovich
                ab@nyitsupport.com / mviscovich@earthlink.net
                06/19/2008
 
 Script Function:
    Rename Computers. Launch the application from anywhere on your network.
    Enter a domain\admin username and password when prompted.
    The script will cycle through the CompRename.csv file looking for OldName,NewName and will rename accordingly.
    The script relies on the netdom.exe file that is a part of the Windows Support Tools. Just extract it from there.
    Look for netdom on download.microsoft.com
 
#ce ----------------------------------------------------------------------------
 
AutoItSetOption("TrayIconHide", 1)
 
$username = InputBox("CompRename", "Please enter domain\admin-username:")
$password = InputBox("CompRename", "Please enter the password:","","*")
 
$FileName = FileOpen("CompRename.csv", 0)
if $FileName = -1 then Exit
 
while 1
    $FileLine = FileReadLine($FileName)
    if @error then 
        FileClose($FileName)
        Exit
    EndIf
    $CompName = StringSplit($FileLine, ",")
    If $CompName[0] = 2 then ShellExecuteWait(@ScriptDir & "\netdom.exe", "RenameComputer " & $CompName[1] & " /NewName:" & $CompName[2] & " /UserD:" & $username & " /PasswordD:" & $password & " /force /reboot:10", @ScriptDir)
WEnd
FileClose($FileName)

Wednesday, June 18, 2008

OLKAway - Remove Outlook Temp Folder At Startup

Delete the contents of the temporary Outlook folder at startup.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=OLKaway.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; This script will delete the OLKxxx or the content.outlook folder under 
; c:\documents and settings\%username%\local settings\temporary internet files\
; It will check for the presense of the OutlookSecureTempFolder entry in the registry
; starting with Outlook 2007, all the way to Outlook 2000 working backwards.
; Once found, it will delete the contents.
; 01/07/2008
; ab@nyitsupport.com
 
AutoItSetOption ("RunErrorsFatal", 0)
AutoItSetOption ("TrayIconHide",1)
 
dim $InstallPath
$InstallPath = "C:\Program Files\NYITSupport\OLKaway\"
 
Select
    case @OSVersion = "WIN_XP"
        Call ("StartSequence")
    case @OSVersion = "WIN_2000"
        $ver = RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions", "ProductType")
        If $ver = "ServerNT" then Exit
        Call ("StartSequence")
    case Else
        Exit
EndSelect    
    
Func StartSequence()
    if $CmdLine[$CmdLine[0]] = "" then 
        call ("CleanUp")
    Else
        Select
            case $CmdLine [1] = "/uninstall"
                if not IsAdmin() then Exit
                call ("Uninstall")
                
            case $CmdLine [1] = "/install" 
                if not IsAdmin() then Exit
                if FileExists($InstallPath) then Exit
                Call ("Install")
        
            case Else
                Exit
                
        EndSelect
    EndIf
EndFunc
 
func CleanUp()
    $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Security", "OutlookSecureTempFolder") ; Outlook 2007
    if @error then $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security\", "OutlookSecureTempFolder") ; Outlook 2003
    if @error then $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Security", "OutlookSecureTempFolder") ; Outlook XP
    if @error then $OSTF = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Outlook\Security", "OutlookSecureTempFolder") ; Outlook 2000
    DirRemove($OSTF,1)
EndFunc
        
Func Install()
    FileCopy (@ScriptFullPath, $InstallPath,8)
    ShellExecute("cacls.exe", '"' & StringLeft($InstallPath, StringLen($InstallPath)-1) & '" /e /c /g BUILTIN\Users:F')
    FileCreateShortcut($InstallPath & "OLKaway.exe", @StartupCommonDir & "\NYITSUPPORT OLKaway.lnk", $InstallPath, "", "NYITSUPPORT OLKaway")
    call ("CleanUp")
EndFunc
 
Func Uninstall()
    FileDelete (@StartupCommonDir & "\NYITSUPPORT OLKaway.lnk")
    DirRemove($InstallPath,1)
EndFunc

Computer Inventory Script With INI Control

I made a network inventory script that collects machine information such as installed applications, mapped drives and printers, network information, and creates backups of the workstations. 

So far it has proven successful in my parent company, where I used a hard coded exe with no INI file version. 

I have since ported it to use an INI file. You can create different INI files based on the department the program will be used for and launch the program as inventory.exe billing.ini

Everything is pretty much self explanatory. Let me know if you have any questions. This was made on 06/20/2007

#include <Array.au3>
#NoTrayIcon
;AutoItSetOption("MustDeclareVars", 1)
 
Dim $INI
Dim $INI_RunApplications, $INI_RunPrinters, $INI_RunDrives, $INI_RunBackup, $INI_RunNetwork
Dim $INI_FileInventory, $INI_FileBKSFile, $INI_FileBKFFile, $INI_FileBackupLogs
Dim $INI_ExitLetter, $INI_ExitFile
Dim $INI_ExcludeAppsDisp[100]
Dim $INI_ExcludeAppsPub[100]
Dim $INI_SortDisplayName, $INI_SortPublisher, $INI_SortDescending
Dim $INI_CommentsApps[3]
Dim $INI_CommentsPrint[3]
Dim $INI_CommentsDrives[3]
Dim $INI_CommentsNetwork[3]
Dim $INI_BackStartMsgLine[10], $INI_BackEndMsgLine[10]
Dim $INI_BackStartMsgEnabled, $INI_BackStartMsgCloseDelay, $INI_BackEndMsgEnabled, $INI_BackEndMsgCloseDelay
Dim $INI_BackupLogType, $key, $INI_BackupHide
Dim $DisplayName
Dim $Publisher
Dim $AppIncrement ;Array increment to be used as a counter and argument passed to the AppWrite function.
Dim $A_Apps[1000]    ;Array to be used for collection of data
Dim $A_Prn[25]
Dim $A_Drv[25]
$ObjNet = ObjCreate("WScript.NetWork") 
 
$INI = $CmdLine[$CmdLine[0]]
If $INI = "" Then $INI = "Inventory.ini" 
If FileExists($INI) = 0 Then Exit 
 
 
Call ("INI_Load")
FileDelete ($INI_FileInventory)
FileOpen ($INI_FileInventory, 10)
If $INI_RunApplications =1 then Call("Applications")
If $INI_RunPrinters = 1 Then Call("Printers")
If $INI_RunDrives = 1 then call("Drives")
If $INI_RunNetwork = 1 Then call ("Network")
If $INI_RunBackup = 1 Then call ("Backup")
FileClose ($INI_FileInventory) ;Close the Inventory file.
 
Func INI_Load() ;INI Load 
;SECTIONS_TO_RUN 
    $INI_RunApplications = IniRead($INI, "SECTIONS_TO_RUN", "Applications",1)
    $INI_RunPrinters = IniRead($INI, "SECTIONS_TO_RUN", "Printers",1)
    $INI_RunDrives = IniRead($INI, "SECTIONS_TO_RUN", "Drives",1)
    $INI_RunNetwork = IniRead($INI, "SECTIONS_TO_RUN", "Network",1)
    $INI_RunBackup = IniRead($INI, "SECTIONS_TO_RUN", "Backup",1)
 
;FILE 
    $INI_FileInventory = IniRead($INI, "FILE", "Inventory","") & "\" & @UserName & "\inventory.txt"
    
    $INI_FileBKSFile = IniRead($INI, "FILE", "BKSFile", "backup.bks")
    $INI_FileBKFFile = IniRead($INI, "FILE", "BKFFile", "inventory.bkf")
    $INI_FileBackupLogs = IniRead($INI,"FILE", "BackupLogs",0)
 
;EXIT_ON_COMPUTERNAME
    For $i = 1 to StringLen(@Computername)
        $INI_ExitLetter = IniRead($INI, "EXIT_ON_COMPUTERNAME", "Letter" & $i,"")
        If $INI_ExitLetter <> "" and $INI_ExitLetter = StringMid (@Computername, $i,1) Then Exit
    Next
 
;EXIT_ON_PRESENT_FILE
    For $i = 1 to 5
        $INI_ExitFile = IniRead($INI, "EXIT_ON_PRESENT_FILE", "File" & $i, "")
        If $INI_ExitFile <> "" and FileExists($INI_ExitFile) Then Exit
    Next
 
;EXCLUDE_APPLICATIONS
    for $i = 1 to 100
        if IniRead($INI, "EXCLUDE_APPLICATIONS", "DisplayName" & $i,"") <> "" then _ArrayAdd ($INI_ExcludeAppsDisp, IniRead($INI, "EXCLUDE_APPLICATIONS", "DisplayName" & $i,""))
        if IniRead($INI, "EXCLUDE_APPLICATIONS", "Publisher" & $i,"") <> "" then _ArrayAdd ($INI_ExcludeAppsPub, IniRead($INI, "EXCLUDE_APPLICATIONS", "Publisher" & $i,""))
    Next
    _ArraySort($INI_ExcludeAppsDisp)
    _ArraySort($INI_ExcludeAppsPub)
 
;COMMENTS
    For $i = 1 to 3
        _ArrayInsert($INI_CommentsApps, $i, IniRead($INI, "COMMENTS", "Applications" & $i, "*****Applications*****"))
        _ArrayInsert ($INI_CommentsPrint, $i, IniRead ($INI, "COMMENTS", "Printers" & $i, "*****Printers*****"))
        _ArrayInsert ($INI_CommentsDrives, $i, IniRead ($INI, "COMMENTS", "Drives" & $i, "*****Drives*****"))
        _ArrayInsert ($INI_CommentsNetwork, $i, IniRead ($INI, "COMMENTS", "Network" & $i, "*****Network Info*****"))
    Next
 
;BACKUP START/END MESSAGE
    $INI_BackStartMsgEnabled = IniRead($INI, "BACKUP_START_MESSAGE", "Enabled", 0)
    $INI_BackStartMsgCloseDelay = IniRead($INI, "BACKUP_START_MESSAGE", "CloseDelay", 20)
    $INI_BackEndMsgEnabled = IniRead($INI, "BACKUP_END_MESSAGE", "Enabled", 0)
    $INI_BackEndMsgCloseDelay = IniRead($INI, "BACKUP_END_MESSAGE", "CloseDelay", 20)
    
    For $i = 1 to 10
        _ArrayInsert ($INI_BackStartMsgLine, $i, IniRead($INI, "BACKUP_START_MESSAGE", "Line" & $i, ""))
        _ArrayInsert ($INI_BackEndMsgLine, $i, IniRead($INI, "BACKUP_END_MESSAGE", "Line" & $i, ""))
    Next
 
;BACKUP
    $INI_BackupLogType = IniRead($INI, "BACKUP", "BackupLogType", "F")
    $INI_BackupHide = IniRead($INI, "BACKUP", "BackupHide", 1)
EndFunc
 
Func Applications() ;--------------------Applications--------------------
    Filewrite ($INI_FileInventory, @CRLF)
    For $i = 1 to 3
        FileWrite ($INI_FileInventory, $INI_CommentsApps[$i] & @CRLF)
    Next
    FileWrite ($INI_FileInventory, "DisplayName" & @TAB & "Publisher" & @CRLF)
    FileWrite ($INI_FileInventory, "----------" & @TAB & "----------" & @CRLF)
    ;Enumerate applitions under HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall key in the registry. Up to 1000 keys.
    
    For $AppIncrement = 1 to 1000 
        $key = RegEnumKey ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", $AppIncrement) 
        if @error <> 0 then ExitLoop
        $DisplayName = RegRead ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $key, "DisplayName")
        $Publisher = RegRead ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $key, "Publisher")
        If $DisplayName <> $Publisher and $DisplayName <> "" Then
            _ArrayInsert ($A_Apps, $AppIncrement, $DisplayName & @TAB & $Publisher & @CRLF)
        EndIf
        Sleep(10)
    Next
    
    _ArraySort ($A_Apps,0,0,1000) ;Sort the array by $DisplayName, or whatever the first variable value in the begging of the line is. - INI
    
    for $i = 1 to UBound($INI_ExcludeAppsDisp,1)-1
        $Pos = _ArraySearch ($A_Apps,$INI_ExcludeAppsDisp[$i],0,0,0,true)
        if $Pos <> -1 then 
            _ArrayDelete($A_Apps, $Pos)
            $i = $i - 1
        EndIf
    Next
    _ArraySort($A_Apps)
    for $i = 1 to UBound($INI_ExcludeAppsPub,1)-1
        $Pos = _ArraySearch ($A_Apps,$INI_ExcludeAppsPub[$i],0,0,0,true)
 
        if $Pos <> -1 then 
            _ArrayDelete($A_Apps, $Pos)
            MsgBox(0,$INI_ExcludeAppsPub[$i],$Pos)
            $i = $i - 1
        EndIf
    Next
 
    _ArraySort ($A_Apps,0,0,1000)
    FileWrite($INI_FileInventory, _ArrayToString($A_Apps, "", 0, UBound($A_Apps,1) -1)) ;Convert the $A_apps array to a string and write the contents to a file.
 
EndFunc
 
func Printers()
    Filewrite ($INI_FileInventory, @CRLF)
    For $i = 1 to 3
        FileWrite ($INI_FileInventory, $INI_CommentsPrint[$i] & @CRLF)
    Next
    
    $ObjPrn = $ObjNet.EnumPrinterConnections
    FileWrite ($INI_FileInventory, "Port" & @TAB & "Printer" & @CRLF)
    FileWrite ($INI_FileInventory, "----------" & @TAB & "----------" & @CRLF)
    For $i = 0 to $ObjPrn.Count -1
        _ArrayInsert($A_Prn, $i, $ObjPrn.Item($i))
    Next
    For $i = 0 to 25
        If $A_Prn[$i] = "" then ExitLoop
        FileWrite ($INI_FileInventory, $A_Prn[$i] & @TAB & $A_Prn[$i + 1] & @CRLF)
        $i = $i + 1
    Next
EndFunc
 
Func Drives()
    Filewrite ($INI_FileInventory, @CRLF)
    For $i = 1 to 3
        FileWrite ($INI_FileInventory, $INI_CommentsDrives[$i] & @CRLF)
    Next
    $ObjDrv = $ObjNet.EnumNetworkDrives
    FileWrite ($INI_FileInventory, "Drive" & @TAB & "Path" & @CRLF)
    FileWrite ($INI_FileInventory, "----------" & @TAB & "----------" & @CRLF)
    For $i = 0 to $ObjDrv.Count -1
        _ArrayInsert ($A_Drv, $i, $ObjDrv.Item($i))
    Next
    For $i = 0 to 25
        If $A_Drv[$i] = "" then ExitLoop
        FileWrite ($INI_FileInventory, $A_Drv[$i] & @TAB & $A_Drv[$i + 1] & @CRLF)
        $i = $i + 1
    Next
EndFunc
 
Func Network()
    Filewrite ($INI_FileInventory, @CRLF)
        For $i = 1 to 3
        FileWrite ($INI_FileInventory, $INI_CommentsNetwork[$i] & @CRLF)
    Next
    FileWrite ($INI_FileInventory, "Computer Name: " & @Tab & @ComputerName & @CRLF)
    FileWrite ($INI_FileInventory, "Username: " & @TAB & @UserName& @CRLF)
    FileWrite ($INI_FileInventory, "Operating System: " & @TAB & @OSVersion & " / " & @OSServicePack & @CRLF)
 
    $strComputer = "."
    $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")
    $nics = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
    For $nic in $nics 
        FileWrite ($INI_FileInventory, "Description:" & @TAB & $nic.Description & @CRLF)
        if $nic.DHCPEnabled = True then FileWrite ($INI_FileInventory, "DHCP Enabled" & @CRLF)
        For $i = 0 To UBound($nics)    ;log IP/SubnetMask
            if $nic.IPAddress($i) <> 0 Then FileWrite ($INI_FileInventory, "IPAddress" & $i & ":" & @TAB & $nic.IPAddress($i) & "/" & $nic.IPSubnet($i) & @CRLF)
            If $nic.DefaultIPGateway($i) <> 0 then FileWrite ($INI_FileInventory, "Gateway" & $i & ":" & @TAB & $nic.DefaultIPGateway($i) & @CRLF)
            If $nic.DNSServerSearchOrder($i) <> 0 then FileWrite ($INI_FileInventory, "DNS" & $i & ":" & @TAB & $nic.DNSServerSearchOrder($i) & @CRLF)
        Next
        FileWrite ($INI_FileInventory, @CRLF)    
        
    Next
EndFunc
 
Func Backup()
    if $INI_BackStartMsgEnabled <> 0 Then MsgBox (262144,"PLEASE READ", _ArrayToString($INI_BackStartMsgLine, @CRLF), $INI_BackStartMsgCloseDelay)
    $NTBACKUP = 'ntbackup.exe' & ' backup "@' & $INI_FileBKSFile & '" /j "Backup" /f "' & $INI_FileBKFFile & "\" & @username & '\Backup.bkf" /A /V:yes /L:' & $INI_BackupLogType & ' /M normal /SNAP:off'
 
    ;hide the backup utility
    Select
        Case $INI_BackupHide = 1
            Run ($NTBACKUP , @SystemDir);run the backup utility
            for $i = 1 to 60
                WinSetState ("Backup Progress", "", @SW_HIDE)
                WinSetState ("Backup Utility - [Untitled]", "", @SW_HIDE)
                WinSetState ("Selection Information", "", @SW_HIDE)
                $i =  $i + 1
                sleep (1000)
            next
            
        Case $INI_BackupHide = 0
            RunWait ($NTBACKUP , @SystemDir);run the backup utility
            
    EndSelect
 
    $BackupState = WinGetState ("Backup Progress", "")
    $BackupUtility = WinGetState ("Backup Utility - [Untitled]")
 
    ;check if the backup is running
    While $BackupState <> 0 
        ;& $BackupUtility <> 0
        Sleep (10000)
        $BackupState = WinGetState ("Backup Progress", "")
        $BackupUtility = WinGetState ("Backup Utility - [Untitled]")
    WEnd
 
    ;Copy over the backup logs
    FileCopy ('c:\Documents and Settings\' & @UserName & '\Local Settings\Application Data\Microsoft\Windows NT\NTBackup\data\*.*', $INI_FileBackupLogs & "\" & @UserName)
    if $INI_BackEndMsgEnabled <> 0 Then MsgBox(262144,"BACKUP COMPLETE", _ArrayToString($INI_BackEndMsgLine, @CRLF), $INI_BackEndMsgCloseDelay)
 
 
EndFunc
 
 

Inventory.ini:

; This INI file is for the Inventory script created by Alex Belenkiy ab@nyitsupport.com
; Do not modify any of the sections or keys of this file, only the values
 
[SECTIONS_TO_RUN] 
;Set 1 to run and 0 to skip
Applications=1
Printers=1
Drives=1
Network=1
Backup=0
 
[FILE]
;Set the path and filename of the inventory and backup files. Use just the filename to create in the program start folder.
;Inventory="\\Server\Share" will result it \\Server\Share\USERNAME\inventory.txt
Inventory=c:\dev
BKSFile=c:\DEV\test.bks
BKFFile=C:\DEV
BackupLogs=C:\DEV
 
[EXIT_ON_COMPUTERNAME]
;Exit the program if a character is present in the computername. To exclude all computers with 
;a second letter dash (ex. J-Doe) use Letter2=-
;To exclude all computers with a 3rd letter D and 5th letter e use Letter3=D Letter11=e
Letter1=
Letter2=
Letter3=
Letter4=
Letter5=
Letter6=
Letter7=
Letter8=
Letter9=
Letter10=
Letter11=
Letter12=
Letter13=
Letter14=
Letter15=
Letter16=
Letter17=
Letter18=
Letter19=
Letter20=
 
[EXIT_ON_PRESENT_FILE]
;Exit the application if a file is present, such as the previously performed inventory or backup.
;Use full path and file name
File1=
File2=
File3=
File4=
File5=
 
[EXCLUDE_APPLICATIONS]
;Application inventory involves checking the HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall key
;To skip applications from being logged, enter their DisplayName or Publisher values,
;excatly as written under the corresponding registry values.
DisplayName1="Ad-Aware"
DisplayName2="Adobe Acrobat"
DisplayName3="Adobe Flash"
DisplayName4="Adobe Reader"
DisplayName5="ATI"
DisplayName6="Blackberry"
DisplayName7="Broadcom"
DisplayName8="Compaq"
DisplayName9="Dameware"
DisplayName10="eSafe eConsole"
DisplayName11="HighMAT"
DisplayName12="Hotfix for Windows"
DisplayName13="HP"
DisplayName14="Intel(r)"
DisplayName15="LiveUpdate"
DisplayName16="Macromedia"
DisplayName17="MetaFrame"
DisplayName18="Microsoft Base"
DisplayName19="Microsoft Data"
DisplayName20="Microsoft Easy"
DisplayName21="Microsoft Exchange"
DisplayName22="Microsoft Inter"
DisplayName23="Microsoft .Net"
DisplayName24="Microsoft Office Live"
DisplayName25="Microsoft Office Professional"
DisplayName26="Microsoft SQL"
DisplayName27="Microsoft User"
DisplayName28="Microsoft National"
DisplayName29="Microsoft Compression"
DisplayName30="Microsoft XML"
DisplayName31="Mozilla"
DisplayName32="OpenMG"
DisplayName33="RealPlayer"
DisplayName34="RecordNow"
DisplayName35="Roxio"
DisplayName36="Security Update"
DisplayName37="Sonic"
DisplayName38="Sony"
DisplayName39="SoundMax"
DisplayName40="Sun Microsystems"
DisplayName41="Symantec Antivirus"
DisplayName42="Track-IT"
DisplayName43="Update for Windows"
DisplayName44="WebEx"
DisplayName45="WebFldrs"
DisplayName46="Windows XP Hotfix"
DisplayName47="WinImage"
DisplayName48="WinZip"
DisplayName49="Yahoo"
DisplayName50="WinRAR archiver"
DisplayName51="Security Update for Windows XP"
DisplayName52="Adobe Download"
DisplayName53="InterVideo WinDVD"
DisplayName54="Windows Driver Package"
DisplayName55="Windows Media"
DisplayName56="Windows Rights"
DisplayName57=
DisplayName58=
DisplayName59=
DisplayName60=
DisplayName61=
DisplayName62=
DisplayName63=
DisplayName64=
DisplayName65=
DisplayName66=
DisplayName67=
DisplayName68=
DisplayName69=
DisplayName70=
DisplayName71=
DisplayName72=
DisplayName73=
DisplayName74=
DisplayName75=
DisplayName76=
DisplayName77=
DisplayName78=
DisplayName79=
DisplayName80=
DisplayName81=
DisplayName82=
DisplayName83=
DisplayName84=
DisplayName85=
DisplayName86=
DisplayName87=
DisplayName88=
DisplayName89=
DisplayName90=
DisplayName91=
DisplayName92=
DisplayName93=
DisplayName94=
DisplayName95=
DisplayName96=
DisplayName97=
DisplayName98=
DisplayName99=
DisplayName100=""
Publisher1="Apple"
Publisher2="Google"
Publisher3="Hewlett"
Publisher4="Intel"
Publisher5="InterVideo Inc."
Publisher6=
Publisher7=
Publisher8=
Publisher9=
Publisher10=
Publisher11=
Publisher12=
Publisher13=
Publisher14=
Publisher15=
Publisher16=
Publisher17=
Publisher18=
Publisher19=
Publisher20=
Publisher21=
Publisher22=
Publisher23=
Publisher24=
Publisher25=
Publisher26=
Publisher27=
Publisher28=
Publisher29=
Publisher30=
Publisher31=
Publisher32=
Publisher33=
Publisher34=
Publisher35=
Publisher36=
Publisher37=
Publisher38=
Publisher39=
Publisher40=
Publisher41=
Publisher42=
Publisher43=
Publisher44=
Publisher45=
Publisher46=
Publisher47=
Publisher48=
Publisher49=
Publisher50=
Publisher51=
Publisher52=
Publisher53=
Publisher54=
Publisher55=
Publisher56=
Publisher57=
Publisher58=
Publisher59=
Publisher60=
Publisher61=
Publisher62=
Publisher63=
Publisher64=
Publisher65=
Publisher66=
Publisher67=
Publisher68=
Publisher69=
Publisher70=
Publisher71=
Publisher72=
Publisher73=
Publisher74=
Publisher75=
Publisher76=
Publisher77=
Publisher78=
Publisher79=
Publisher80=
Publisher81=
Publisher82=
Publisher83=
Publisher84=
Publisher85=
Publisher86=
Publisher87=
Publisher88=
Publisher89=
Publisher90=
Publisher91=
Publisher92=
Publisher93=
Publisher94=
Publisher95=
Publisher96=
Publisher97=
Publisher98=
Publisher99=
Publisher100=
 
[COMMENTS]
Applications1="**************************************"
Applications2="**********   Applications   **********"
Applications3="**************************************"
Printers1=**************************************
Printers2=**********     Printers     **********
Printers3=**************************************
Drives1=**************************************
Drives2=**********      Drives      **********
Drives3=**************************************
Network1=**************************************
Network2=**********   Network Info   **********
Network3=**************************************
 
[BACKUP_START_MESSAGE]
;Message to display after inventory, but before backup. Set Enabled to 0 to disable.
;CloseDelay will close the message after a predetermined amount of time in seconds.
;The user can also click OK to close it earlier.
Enabled=1
CloseDelay=20
Line1=Your computer is currently being backed up by the IT department engineers.
Line2=Please do not shut down or restart your computer until the backup is complete
Line3=The backup may take up to 30 minutes, you will be notified upon completion
Line4=If you have any questions please call 212-555-1212.
Line5=You may continue to work with your applications as usual while the backup is in progress.
Line6=Please do not save or edit any more files on the 'Local C' drive after the backup job is complete.
Line7=
Line8=
Line9=
Line10=
 
[BACKUP_END_MESSAGE]
;Message to display after the backup is complete.
Enabled=1
CloseDelay=20
Line1=The Backup was complete
Line2=Thank you
Line3=
Line4=
Line5=
Line6=
Line7=
Line8=
Line9=
Line10=
 
[Backup]
BackupHide=1
BackupLogType=S