Friday, November 20, 2009

All about command line for SQL Server

http://www.haidongji.com/2006/12/19/executing-sql-scripts-using-command-line-tools/

Search and Replace in Windows

Save below code in a file called replace.vbs.

Call this using below command

cscript searchAndReplace.vbs xxx ccc myfile.txt

It will replace all xxx with ccc


Dim FileName, Find, ReplaceWith, FileContents, dFileContents
Find = WScript.Arguments(0)
ReplaceWith = WScript.Arguments(1)
FileName = WScript.Arguments(2)

'Read source text file
FileContents = GetFile(FileName)

'replace all string In the source file
dFileContents = replace(FileContents, Find, ReplaceWith, 1, -1, 1)

'Compare source And result
if dFileContents <> FileContents Then
'write result If different
WriteFile FileName, dFileContents

Wscript.Echo "Replace done."
If Len(ReplaceWith) <> Len(Find) Then 'Can we count n of replacements?
Wscript.Echo _
( (Len(dFileContents) - Len(FileContents)) / (Len(ReplaceWith)-Len(Find)) ) & _
" replacements."
End If
Else
Wscript.Echo "Searched string Not In the source file"
End If

'Read text file
function GetFile(FileName)
If FileName<>"" Then
Dim FS, FileStream
Set FS = CreateObject("Scripting.FileSystemObject")
on error resume Next
Set FileStream = FS.OpenTextFile(FileName)
GetFile = FileStream.ReadAll
End If
End Function

'Write string As a text file.
function WriteFile(FileName, Contents)
Dim OutStream, FS

on error resume Next
Set FS = CreateObject("Scripting.FileSystemObject")
Set OutStream = FS.OpenTextFile(FileName, 2, True)
OutStream.Write Contents
End Function

Monday, November 16, 2009

Active Driectory manipulation using VB Scripts

http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/usersgroups/users/

Saturday, November 14, 2009

Great Python Tutorial

http://groups.google.com/group/secrets-of-the-framework-creators/files

Monday, November 09, 2009

Adobe Reader Installer Automation

FEAD Optimizer is a system that is used to compress installation files into a highly compact distributable file. The intention is of course to save on bandwidth and make installation a lot more reliable. The FEAD compressed file works sort of like an executable ZIP file. But unlike a ZIP file there are no third party tools that allow the contents to be extracted easily to a folder, also there are no command line options posted on the Netopsystems website.
In my experience of FEAD Optimized files, they take a very long time to re-compose on the target machine. When you multily the re-compose time on lots of machines, you start to wonder how to decompress the files and save yourself precious time.
Until now, the only method that I have found effective in locating the re-composed files, is to use FileMon (from www.sysinternals.com) and monitor the location of where the files are being stored. Then copying the files to a safe location and cancelling the software installation. I can then use the MSI files to deploy the software using Active Directory or the RM CC3 Management tools.
I have even emailed Netopsystems asking if there are command line options, but they have never replied. I had given up hope of ever finding the command line switches until I came across them in an installation manual for a product that uses the FEAD system.
FEAD Command line switches -nos_ne No execution ? Extracts the files from the Setup utility but does not execute the Setup utility or delete the setup files.-nos_nd No delete ? Does not remove the setup files after executing the Setup utility. If the -nos_-ne switch is also present, the -nos_-nd switch is overridden.
-nos_d Delete ? Removes the setup files after executing the Setup utility. If the -nos_-ne switch is also present, the -nos_-d switch is overridden.

-nos_s Silent mode ? Installs the setup files in silent mode. Installs automatically when using: /s, /S, -s, -S, /q, /Q, -q, -Q.

-nos_o"" Output folder ? The folder to which you want to extract the setup files.

So running the executable with the following command line switches will extract the files from the FEAD archive to a location of your choosing and not execute the setup file.
program.exe -nos_ne -nos_o"C:\FEAD_Extracted"
It is also possible to send parameters to the setup/MSI file inside the FEAD archive, for example this command would change the default installation path of an MSI installer.
program.exe -nos_d INSTALLDIR="C:\Program Files\Install Here"
To run an automated silent install of a contained MSI file use this command
program.exe -nos_d /qb
As you can see, the FEAD file is actually a lot more flexiable than it appears to be and I am supprised that Netopsystems don't put this type of information onto their support site. After all they are selling deployment software to big companies who intern sell the software to other big companies who need to deploy software with more flexibility.
Common Applications that use the FEAD Optimizer format are;
Adobe Acrobat Reader 6

Adobe Acrobat Reader 7
McAfee VirusScan 8.0i

McAfee VirusScan 7.10

and many more...

The command line options work for both version 1 and 2 of the FEAD system
I hope that you will have found this useful and that it will save you hours of figuring out how to save yourself time and effort waiting for the optimiser to finish re-composing the files that you need.
Download the FEAD Extractor Tool so that you don't need to fuss with the command line parameters.
http://www.schooltechnician.co.uk/knowledge_base/general/fead_optimizer_extract_tool.html

Silent Install Parameters

Adobe Acrobat Reader 6.0 AdbeRdr60_enu_full.exe -p"-s /v\"/qn\"")
Adobe Acrobat Reader 6.0 AdbeRdr60_enu_full.exe
.NET Framework dotnetfx.exe /Q:A /R:N /C:\"install.exe /Q:A /R:N\"
7-Zip 7Zip.exe -y /q /r:n
Acrobat Reader 7.0 AdbeRdr705_esp_full.exe /w /v"/qb"
AdbeRdr60_enu_full
AdbeRdr60_enu_full.exe AdbeRdr60_enu_full.exe
adobe adobe.ex -p
Adobe Acrobat Reader
Adobe Acrobat Reader AdbeRdr60_enu_full.exe like -p"-s /v\"/qn\"")
Adobe Acrobat Reader 6.0 AdbeRdr60_enu_full.exe -p"-s /v\"/qn\""
Adobe Acrobat Reader 6.0 AdbeRdr60_hun.exe /qn
Adobe Acrobat Reader 6.0 AdbeRdr60_enu_full.exe -p"-s /v\"/qn\""
Adobe Acrobat Reader 7.0 AdbeRdr60_enu_full.exe -p"-s /v\"/qn\""
Adobe Acrobat Reader 7.0 like AdbeRdr60_enu_full.exe like -p"-s /v\"/qn\""
firefox firefox.exe -p intalar!!!
Flash Player 7.0 flashplayer7installer.exe /S
J2SE(TM) Runtime Enviroment 5.0 Update 4 jre-1_5_0_04-windows-i586-p.exe /s /v"/qb ADDLOCAL=ALL"

J2SE(TM) Runtime Enviroment 5.0 Update 4 jre-1_5_0_04-windows-i586-p.exe /s /v"/qb ADDLOCAL=ALL"

Mozilla Firefox 1.5 Firefox Setup 1.5.exe -ms
MSXML 4 SP msxml.msi /qb REBOOT=REALLYSUPPRESS
nero nero.exe /Q:A /R:N /C:\"setup_wm.exe /Q:A /R:N /DisallowSys
Office 2003 Professional SETUP.EXE TRANSFORMS=einstellungen.mst /qb-
Opera 8.50 ow32enen850.exe /S
ShockWawe 10.0.0.210 Shockwave_Installer_Full.exe /S
Windows Media Player 10 MP10Setup.exe /q:A /c:"setup_wm.exe /Q /R:N /DisallowSystemRest
winzip winzip90.exe /S

Monday, November 02, 2009

Learn Design Patterns

http://perfectjpattern.sourceforge.net/

Great Jython tutorial

http://onjava.com/pub/a/onjava/2002/03/27/jython.html

Swing with Jython - I

from javax.swing import *


#from java.awt.event import *

from java.awt import *

from java.lang import *



win = JFrame("This is a frame")

win.bounds = 100,100,100,100

win.defaultCloseOperation = 3 #EXIT_ON_CLOSE



menuBar = JMenuBar()

fileMenu = JMenu("File")

menuBar.add(fileMenu);



newMenuItem = JMenuItem("New")

newMenuItem.actionPerformed=lambda event : System.out.println("Clicked on New Menu Item")

fileMenu.add(newMenuItem)



openMenuItem = JMenuItem("Open")

openMenuItem.actionPerformed=lambda event : System.out.println("Clicked on Open Menu Item")

fileMenu.add(openMenuItem)



saveMenuItem = JMenuItem("Save")

saveMenuItem.actionPerformed=lambda event : System.out.println("Clicked on Save Menu Item")

fileMenu.add(saveMenuItem)

saveMenuItem.enabled = 0 #false



win.JMenuBar = menuBar



contentPane = win.contentPane

contentPane.layout = GridLayout()



buttonOne = JButton("Button One")

buttonOne.actionPerformed=lambda event : System.out.println("Clicked on Button One")

contentPane.add(buttonOne)



buttonTwo = JButton("Button Two")

buttonTwo.actionPerformed=lambda event : System.out.println("Clicked on Button Two")

contentPane.add(buttonTwo)



buttonThree = JButton("Button Three")

buttonThree.actionPerformed=lambda event : System.out.println("Clicked on Button Three")

contentPane.add(buttonThree)



win.pack()

win.show()