Search This Blog

Friday, March 12, 2010

Blackberry DB Backup BESMgmt BlackberryDBBackup.exe

Ok, so if anyone is interested in backing up the MSDE database for the Blackberry Enterprise Server, you may have come across a command called blackberrydbbackup.exe. 
And you most likely would have run into issues with using it. 

The help, when executing the program without switches shows a command -d for specifying the database, -E for using windows credentials, and -f for the backup folder:
 
blackberrydbbackup.exe -d BESMgmt -E -f c:\backup 

That does not work, no matter what you seem to do, even though Blackberry support and all forums show it as being the proper command sequence. 

Well after a half hour of hitting my head against the wall, a solution was born:

blackberrydbbackup -dBESMgmt -E -f c:\backup 

Note the no space after the -d and the .exe taken out. 
When the script was written, it seems someone made a few mistakes. 
The .exe extension is taken as a part of the switch it seems, and the help needs to be modified to reflect the -dDBname. 

Dont even bother using -U and -P for username and password. Nothing i tried worked. 
-Udomain\besadmin 
-Udomain\BESAdmin 
-U domain\besadmin 
-U domain\BESAdmin 
-Ubesadmin 
-UBESAdmin 
-U BESAdmin 
-U besadmin 
-UBESAdmin@domain 
-U BESAdmin@domain 
-U:all of the above and the same for -P of course. 

When scheduling the script for this using Windows Scheduler, -E is enough, as the windows credentials will be passed. 
Just enter the besadmin info when saving the job. 

Someone posted online about using the AT command to run as a system service along with -U and -P so as to not have to change the password for the job each time the Besadmin pw changed. 
That makes no difference, as even if you got the -U and -P to work properly, when the besadmin pw is changed you would still have to modify the script with the new -P. 

By the way the tool along with blackberrydbrestore.exe is located in the tools folder on the Blackberry cd. 

 Thank you

Friday, October 9, 2009

OLKAway Now With Vista support

Long overdue update.

Added Vista support, removed old AutoIT declarations, and set the temp folder to be recreated after deletion to avoid random errors.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=OLKaway.exe
#AutoIt3Wrapper_Compression=4
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    This script will delete the Outlook temp folder under
    c:\documents and settings\%username%\local settings\temporary internet files\OLKxxx (Windows XP/2000)
    or 
    C:\Users\%username%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook (Windows Vista)
    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.
    /install option will add a shortcut to the startup folder.
    /uninstall option will delete the shortcut.
    no option will just execute the removal without installing.
    created 01/07/2008
    updates 10/09/2009
        Added Vista support
        Removed old AutoIT declarations
        Corrected random Outlook issues due to the temp folder not being recreated, by creating it manually after each delete.
    
    ab@nyitsupport.com
#ce
 
dim $InstallPath
$InstallPath = "C:\Program Files\NYITSupport\OLKaway\"
 
Select
    case @OSVersion = "WIN_VISTA"
        #requireadmin
        Call ("StartSequence")
    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)
    DirCreate($OSTF)
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

Tuesday, July 14, 2009

WSUS Problems On Cloned Machines

I ran into an interesting issue the other day. A machine registered in WSUS would appear and then dissapear from the WSUS 3 SP1 console.

Found the solution to the problem on the following links:

http://blog.netnerds.net/2006/12/wsus-force-registration-of-clients-that-are-not-showing-up/ – best source

https://www.experts-exchange.com/questions/23550840/Computers-disappearing-from-WSUS.html

Here is a script that will run only once if completed successfully. It will also write a log in either case to a subfolder where it ran from with a computer name in the file name.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=WSUSFix.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    WSUSFix
        This application will repair WSUS issues that may have been caused by the machine being imaged.
        
        Referrenced from:
            http://www.wsuswiki.com/ClientFAQ
            http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/2003_Server/Q_23550840.html
            http://blog.netnerds.net/2006/12/wsus-force-registration-of-clients-that-are-not-showing-up/
    Alex Belenkiy
    ab@nyitsupport.com
    07/15/2009
#ce
 
If Not IsAdmin() then Exit ; check for admin rights
if @OSVersion <> "WIN_XP" then Exit ; Only install on Windows XP
 
if FileExists("c:\windows\WSUS\WSUSFixComplete.txt") then Exit
 
dim $error, $File, $log, $logText
 
$command = RunWait(@ComSpec & " /c " & "net stop wuauserv")
if @error then 
    call("Logger", "net stop wuauserv FAILED")
    $error = 1
Else
    call("Logger", "net stop wuauserv SUCCESSFUL")
EndIf
 
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "AccountDomainSid") 
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "PingID") 
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate", "SusClientId") 
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "LastWaitTimeout")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "DetectionStartTime")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "NextDetectionTime")
Call("RegFix", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update", "AUState")
 
$command = RunWait(@ComSpec & " /c " & "net start wuauserv")
if @error then 
    call("Logger", "net start wuauserv FAILED")
    $error = 1
Else
    call("Logger", "net start wuauserv SUCCESSFUL")
EndIf
 
$command = RunWait(@ComSpec & " /c " & "wuauclt /resetauthorization /detectnow")
if @error then 
    call("Logger", "wuauclt /resetauthorization /detectnow FAILED")
    $error = 1
Else
    call("Logger", "wuauclt /resetauthorization /detectnow SUCCESSFUL")
EndIf
 
if $error <> 1 then ; install completed successfully don't run again.
    $File = FileOpen("c:\windows\WSUS\WSUSFixComplete.txt",9)
    call ("Logger", "WSUS Fix completed successfully")
Else ; install did not complete successfully, write a log and allow for another try
    call ("Logger", "WSUS Fix encountered errors. Will try again at next startup.")
EndIf
 
Func Logger($logText) ; write a log
    $log = FileOpen(@ScriptDir & "\Logs\" & @ComputerName & ".log", 9)
    if not @error Then
        FileWriteLine($log, @CRLF & $logText & " - " & @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN)
        FileClose($log)
    EndIf
EndFunc
 
Func RegFix($RegKey, $RegVal)
    $Command = RegRead($RegKey, $RegVal)
    if not @error Then
        call("Logger", "RegRead " & $RegKey & " " & $RegVal & " " & "LOCATED")
        $Command = RegDelete($RegKey, $RegVal)
        if @error then 
            $error = 1
            call("Logger", "RegDelete " & $RegKey & " " & $RegVal & " " & "FAILED")
        Else
            call("Logger", "RegDelete " & $RegKey & " " & $RegVal & " " & "SUCCESSFUL")
        EndIf
    Else
        call("Logger", "REGREAD " & $RegKey & " " & $RegVal & " " & "NOT FOUND")
    EndIf
EndFunc

Wednesday, March 18, 2009

Serial Number Retriever

Yet another serial number generator. Ported from a vbscript found online.
Just feed a machine name to the script to get an output with a serial number into a csv file.
You can also feed a file with all computer names on separate lines. If executed with no options, the current computer info is returned.
If there is no input, the local machine will be used.

 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
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=SerialNumber.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
	Yet another serial number generator. Ported from a vbscript found online.
	Just feed a machine name to the script to get an output with a serial number into a csv file.
	You can also feed a file with all computer names on separate lines. If executed with no options, the current computer info is returned.
	If there is no input, the local machine will be used.
	
	Alex Belenkiy
	09/24/08


#ce
#include <array.au3>
#include <file.au3>

dim $strComputer, $ComputersArray

$OutputFile = FileOpen("ServiceTag " & @MON & "-" & @MDAY & "-" & @YEAR & ".csv", 10)
FileWriteLine($OutputFile, "Machine Name, Manufacturer, Model Number, Serial Number, Part Number, SMBIOSAssetTag, OtherIdentifyingInfo")
If $CmdLine[0] = 0 Then 
	$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
	$colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")	
	For $objSMBIOS in $colSMBIOS
		FileWriteLine($OutputFile, @ComputerName & "," & $objSMBIOS.Manufacturer & "," & $objSMBIOS.Model & "," & $objSMBIOS.SerialNumber & "," & $objSMBIOS.PartNumber & $objSMBIOS.SMBIOSAssetTag & $objSMBIOS.OtherIdentifyingInfo)
	Next
Else
	if not FileExists($CmdLine[1]) Then
		$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $CmdLine[1] & "\root\cimv2")
		if not @error Then
			$colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")	
			For $objSMBIOS in $colSMBIOS
				FileWriteLine($OutputFile, $CmdLine[1] & "," & $objSMBIOS.Manufacturer & "," & $objSMBIOS.Model & "," & $objSMBIOS.SerialNumber & "," & $objSMBIOS.PartNumber & $objSMBIOS.SMBIOSAssetTag & $objSMBIOS.OtherIdentifyingInfo)
			Next
		EndIf
	Else
		_FileReadToArray($CmdLine[1],$ComputersArray)
		For $a = 1 to $ComputersArray[0]
			$objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $ComputersArray[$a] & "\root\cimv2")
			if not @error Then
				$colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")	
				For $objSMBIOS in $colSMBIOS
					FileWriteLine($OutputFile, $ComputersArray[$a] & "," & $objSMBIOS.Manufacturer & "," & $objSMBIOS.Model & "," & $objSMBIOS.SerialNumber & "," & $objSMBIOS.PartNumber & $objSMBIOS.SMBIOSAssetTag & $objSMBIOS.OtherIdentifyingInfo)
				Next
			EndIf
		Next
	EndIf
EndIf
	
		
FileClose($OutputFile)

Folder Duplicator

This script lets you choose a folder and copy it to every subfolder in the chosen destination.

Created it with a specific purpose of updating 200+ Citrix server user folders.

A catalog configuration file for Document Locator had to be placed under c:\documents and settings\username\application data\ColumbiaSoft

I created a folder called Application Data, then ColumbiaSoft under it, and placed the catalog there. Ran the script, selected the new Application Data folder, and chose c:\documents and settings as the destination. The script merged the existing application data with the new one under each username folder. Please pay attention as the script will overwrite existing files without prompting.

 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
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=FolderDuplicator.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs
    FolderDuplicator
    03/11/2009
    Alex Belenkiy - ab@nyitsupport.com
    
    This script will duplicate the source directory into every subfolder of the destination, 
    overwriting existing files in it's path.
    Use with caution!!!
    
#ce
 
#Include <File.au3>
 
$Warning = MsgBox(1, "Folder Duplicator", "This application will duplicate the selected" & @CRLF & "source folder into all destination subfolders" & @CRLF & "All existing files will be overwritten")
if $Warning = 2 then Exit
$source = FileSelectFolder("Select Folder to Copy", "")
if @error Then 
    MsgBox(0, "Folder Duplicator", "Invalid Source Folder")
    Exit
EndIf
$destination = FileSelectFolder("Select Destination Folder", "")
if @error then 
    MsgBox (0, "Folder Duplicator", "Invalid Destination Folder")
    Exit
EndIf
 
$sourceSplit = StringSplit($source, "\")
If StringRight($destination, 1) <> "\" Then $destination &= "\"
$FileList = _FileListToArray ($destination, "*.*", 2)
if @error then Exit
 
for $a = 1 to $FileList [0]
    DirCopy ($source, $destination & $FileList[$a] & "\" & $sourceSplit[$sourceSplit[0]], 1)
    
    if @error then
        MsgBox(0, "Folder Duplicator", "Error encountered while copying folders")
        Exit
    EndIf
Next
MsgBox(0,"Folder Duplicator", "Done!!!")