Archive - July 2010

"Action is the real measure of intelligence" - Napolean Hill 
 

Index
bar1
Launching Commands And Pausing In Javascript
Nice Little Google Wait/Busy HTA
Safari Silent Deployment
Mozilla Silent Deployment
Google Chrome Silent Deployment
Load Registry Key With A Token + Hidden Process
How To Create A Shortcut In VBScript
Password Box In HTA
 
bar1





 
Δ Wednesday, July 21st 2010
bar1
  
 
 
Δ
Launching Commands And Pausing In Javascript
 
How to launch an execute command and pause in javascript

Javascript
  

bar1
<script type="text/javascript">
var i = 0;
window.onload = start;

function FadeFunction1() {
if (i < 1500)
{
i=i+1;
}
var d = document.body.style
d.filter = "alpha(Opacity="+i+")"
d.opacity = i/1500
var num = document.all ? 1 : 1500
setTimeout("FadeFunction1()",num)
}

function executeCommand()
{
// Instantiate the Shell object and invoke
//its execute method.

var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "c:\\windows\\notepad.exe";

// Invoke the execute method.
oShell.ShellExecute(commandtoRun, "", "", "open", "1");
}

function pause(milliseconds) {
var dt = new Date();
while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}

function start() {
FadeFunction1();
}


</script>

bar1


bar1

  
  
  
 
  
Δ Tuesday, July 13th 2010
bar1
 
  

Δ Nice Little Google Wait/Busy HTA

 
How to create a borderless wait-busy hta
(Useful for displaying wait-busy to end-user)

[Link to files]

Imagine this in the center of the screen, turning for a specific amount of time.     

passbox

  

bar1
<script language="vbscript">
'This loads hta offscreen, stops the HTA flicker
Window.ReSizeTo 0,0
Window.moveTo -500, 0
</script>


<!--
===============================================================
Name: Progress Bar
Author: Eddie Jackson
Contact: Eddie.Jackson@advref.com
Created on: 07/15/2010
Modified:
Modified by:
Description: General use progress for google chrome browser
===============================================================
-->

<HTML>
<HEAD>
<TITLE>Progress Bar</TITLE>
<HTA:APPLICATION ID="Progress Bar"
BORDER="none"
INNERBORDER="no"
SCROLL="no"
CAPTION="no"
SHOWINTASKBAR="no"
SINGLEINSTANCE="no"
SYSMENU="no"
CONTEXTMENU="no"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
WINDOWSTATE="normal"
>

<STYLE> body {margin:0}
</STYLE>

</HEAD>


<BODY bgcolor="black">
<center>

<frameset framespacing="0"; border="0"; bgcolor="black">
<iframe src="progress.gif"; name="google"; hspace="-185"; vspace="-115"; scrolling="no"; allowtransparency="true"; style="height: 180%; width: 175%; border: 0px solid black;">
</iframe>
</frameset>


<b><h3><span id="DataArea"></span></h3></b>
</center>


<SCRIPT Language="VBScript">
On error resume next

Sub Window_Onload
On error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
End Sub

'sub launch(pgm)
' On error resume next
' set shell = createobject("wscript.shell")
' shell.run pgm
' end sub

Sub Window_OnLoad
On error resume next
w = 160
h = 150
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)

'THIS WILL KILL THE PROGRESS BAR AFTER 16 SECONDS+-
Set objShell = CreateObject("WScript.Shell")
command = "cmd /c ping -n 16 127.0.0.1 & taskkill /f /im mshta.exe"
objShell.Run command,0, False
End Sub

Function ResizeWindow(w, h)
On error resume next
width = w
height = h
window.resizeTo width, height
End Function

Function CenterWindow(w, h)
On error resume next
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y

'THIS READS IN THE DYNAMIC PROGRESS MESSAGE
''ForReading = 1
''Set objFSO = CreateObject("Scripting.FileSystemObject")
''Set objFile = objFSO.OpenTextFile("c:\program files\ultrasite32\msg.txt", ForReading)
''strLine = objFile.ReadLine
''msgbox strLine
DataArea.InnerHTML = "" 'you could add a static message here
''objFile.Close
End Function

</SCRIPT>
</BODY>
</HTML>

bar1


bar1

  
 
 

 
Δ Thursday, July 08th 2010
bar1
 
 
 

Δ
Safari Silent Deployment
 
How to install and uninstall Apple Safari browser 5.33.16.0 silently

Safari browser silent installation
 
 

bar1
cmd /c msiexec /i C:\SetupFiles\safari\Safari.msi /qb
bar1


 
Safari browser 5.33.16.0 silent uninstall
 
 

bar1
cmd /c MsiExec.exe /X{AFAC914D-9E83-4A89-8ABE-427521C82CCF} /qb
bar1

 



VBScript which can be used inside a MSI for Group Policy deployment.
    

bar1
On error resume next
Dim WshShell, objFSO, filesys
SET filesys = CreateObject("Scripting.FileSystemObject")

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")


'ENTER MAIN ROUTINE

If filesys.FileExists("C:\SetupFiles\safari\Safari.msi") THEN
On error resume next
'INSTALLS APPLICATION SUPPORT.
WshShell.Run "cmd /c c:\windows\system32\msiexec /i ""C:\_ResourceFiles\safari\Safari.msi"" /qn /norestart", 0, True
WScript.Quit
End if


'THIS WILL BE THE UNINSTALLATION ROUTINE
If NOT filesys.FileExists("C:\SetupFiles\safari\Safari.msi") THEN
on error resume next

'UNINSTALLS APPLLICATION
WshShell.Run "cmd /c c:\windows\system32\msiexec /x ""{AFAC914D-9E83-4A89-8ABE-427521C82CCF}"" /qn /norestart", 0, True
WSCRIPT.QUIT
END IF

WScript.Sleep 5000
WSCRIPT.QUIT
bar1

 

 

 
Δ Mozilla Silent Deployment
 
How to install and uninstall Mozilla Firefox browser 3.6.6 silently

Firefox browser silent installation
 
 

bar1
cmd /c "C:\SetupFiles\mozilla\Firefox Setup 3.6.6.exe" -ms /ini=c:\windows\system32\mozilla.ini

:ini file, which I placed into the system32 folder
[Install]
; The name of the directory where the application will be installed in the
; system's program files directory. The security
; context the installer is running in must have write access to the
; installation directory. Also, the directory must not exist or if it exists
; it must be a directory and not a file. If any of these conditions are not met
; the installer will abort the installation with an error level of 2. If this
; value is specified then InstallDirectoryPath will be ignored.
InstallDirectoryName=Mozilla Firefox

; The full path to the directory to install the application. The security
; context the installer is running in must have write access to the
; installation directory. Also, the directory must not exist or if it exists
; it must be a directory and not a file. If any of these conditions are not met
; the installer will abort the installation with an error level of 2.
InstallDirectoryPath=c:\firefox\

; By default all of the following shortcuts are created. To prevent the
; creation of a shortcut specify false for the shortcut you don't want created.
;
; Create a shortcut for the application in the current user's QuickLaunch
; directory.
QuickLaunchShortcut=false
;
; Create a shortcut for the application on the desktop. This will create the
; shortcut in the All Users Desktop directory and if that fails this will
; attempt to create the shortcuts in the current user's Start Menu directory.
DesktopShortcut=true
;
; Create shortcuts for the application in the Start Menu. This will create the
; shortcuts in the All Users Start Menu directory and if that fails this will
; attempt to create the shortcuts in the current user's Start Menu directory.
StartMenuShortcuts=true

; The directory name to use for the StartMenu folder.
; note: if StartMenuShortcuts=false is specified then this will be ignored.
StartMenuDirectoryName=Mozilla Firefox

bar1


 
Firefox browser 3.6.6 silent uninstall

bar1
cmd /c "C:\Program Files\Mozilla Firefox\uninstall\helper.exe" /S
bar1



 
 

VBScript which can be used inside a MSI for Group Policy deployment.
  

bar1
On error resume next
Dim WshShell, objFSO, filesys
SET filesys = CreateObject("Scripting.FileSystemObject")

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")


'ENTER MAIN ROUTINE

If filesys.FileExists("C:\_ResourceFiles\mozilla\Firefox Setup 3.6.6.exe") THEN
On error resume next
'INSTALLS APPLICATION SUPPORT.
WshShell.Run "cmd /c ""C:\SetupFiles\mozilla\Firefox Setup 3.6.6.exe"" -ms
/ini=c:\windows\system32\mozilla.ini", 0, True
WScript.Quit
End if

'THIS WILL BE THE UNINSTALLATION ROUTINE
If NOT filesys.FileExists("C:\SetupFiles\mozilla\Firefox Setup 3.6.6.exe") THEN
on error resume next
'UNINSTALLS APPLLICATION
WshShell.Run "cmd /c ""C:\Program Files\Mozilla Firefox\uninstall\helper.exe"" /S", 0, True
WScript.Quit
END IF

WScript.Sleep 5000
WSCRIPT.QUIT

bar1




Δ Google Chrome Silent Deployment
 
How to install and uninstall Google Chrome browser 5.0.375 silently

Chrome browser silent installation - I got this file by quickly capturing .exe contents from the temp folder.
 
 
 

bar1
cmd /c C:\SetupFiles\chrome\375.70_chrome_installer.exe /s
bar1


 

Chrome browser 5.0.375 silent uninstall - I got the setup.exe from the user's application data folder.
         

bar1
5.0.375 browser
C:\SetupFiles\chrome\5.0.375.70\Installer\setup.exe --uninstall --force-uninstall

google updater
MsiExec.exe /X{A92DAB39-4E2C-4304-9AB6-BC44E68B55E2} /quiet

gmail notify
MsiExec.exe /X{2FA41EBB-3F5A-35C3-85D6-51EC72A11FBD} /quiet

google toolbar
MsiExec.exe /x{DBEA1034-5882-4A88-8033-81C4EF0CFA29} /quiet

google talk
"C:\Program Files\Google\Google Talk\uninstall.exe"

bar1




VBScript which can be used inside a MSI for Group Policy deployment. 

   

bar1
On error resume next
Dim WshShell, objFSO, filesys
SET filesys = CreateObject("Scripting.FileSystemObject")

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")


'ENTER MAIN ROUTINE

If filesys.FileExists("C:\SetupFiles\chrome\375.70_chrome_installer.exe") THEN
On error resume next
'INSTALLS APPLICATION SUPPORT.
WshShell.Run "cmd /c ""C:\SetupFiles\chrome\375.70_chrome_installer.exe"" /s", 0, True
WScript.Quit
End if

'THIS WILL BE THE UNINSTALLATION ROUTINE
If NOT filesys.FileExists("C:\SetupFiles\chrome\375.70_chrome_installer.exe") THEN
on error resume next
'UNINSTALLS APPLLICATION
WshShell.Run "cmd /c ""C:\SetupFiles\chrome\5.0.375.70\Installer\setup.exe"" --uninstall --force-uninstall", 0,
True
WScript.Quit
END IF

WScript.Sleep 5000
WSCRIPT.QUIT

bar1




VBScript which can be used inside of a MSI to close security sensitive window and copy first time shortcut to desktop.
 

bar1
On error resume next
'Create InSite Shortcut
On error resume next
DIM filesys, oShortCut
SET oShell = CreateObject("WScript.Shell")
SET filesys = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set oWshNet = CreateObject("WScript.Network")
' use current computer
sComputerName = oWshNet.ComputerName

sUserName = GetConsoleUser(sComputerName)
If sUserName <> "" Then
'MsgBox "Console user name: " & sUserName
Else
'MsgBox "Console user name not found with QWINSTA.EXE"
End If

Function GetConsoleUser(sHost)
' Function will return console user name from QWINSTA.EXE
' Windows XP and Win2k3 Server only

Set oShell = CreateObject("Wscript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")

sTempFile = oFS.GetSpecialFolder(2).ShortPath & "\" & oFS.GetTempName

'Run command via Command Prompt and use for /f to extract user name
'Dump results into a temp text file
oShell.Run "%ComSpec% /c for /f ""skip=1 Tokens=2"" %i in " & "('%SystemRoot%\System32\QWINSTA.EXE console /SERVER:" & sHost & "') do echo %i >" & sTempFile, 0, True

GetConsoleUser = "" 'init value

If oFS.FileExists(sTempFile) Then
'Open the temp Text File and Read out the Data
Set oTF = oFS.OpenTextFile(sTempFile)

'Parse the text file
Do While Not oTF.AtEndOfStream
GetConsoleUser = Trim(oTF.ReadLine)
Loop

'Close it
oTF.Close
'Delete It
oFS.DeleteFile sTempFile
End If

End Function

'wait 7 seconds - this allows the pkzipc.exe 5.0.375.70 directory extract enough time
WScript.Sleep 7000

'if command file exists monitor first launch google process to be closed automatically
'-this needs to be closed because it will be running under escalated security context
If filesys.FileExists("C:\_ResourceFiles\chrome\First time launch.cmd") THEN
on error resume next
'set shell1 = createobject("wscript.shell")
'shell1.AppActivate "Welcome to Google Chrome"
'x = 0
'c = 0
'do while x = 0
' success1 = shell1.appactivate("Welcome to Google Chrome")
' if success1 then
' shell1.sendkeys "{ESC}"
' ' shell1.sendkeys "%c"
' x = 1
' end if
' WScript.Sleep 25
' c = c + 1
' if c > 150 then x = 1
' loop

'wait 8 seconds - this allows the pkzipc.exe 5.0.375.70 directory extract enough time
WScript.Sleep 8000

'copy the first launch shortcut which is customized to launch chrome.exe and build google profile
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\_ResourceFiles\chrome\First time launch.lnk", "c:\Documents and Settings\"&sUserName&"\Desktop\First Time Launch.lnk", OverwriteExisting

'kill the pkzipc.exe - kills any hung process
strCommand1 = "CMD /c c:\windows\system32\taskkill.exe /f /im pkzipc.exe"
oShell.Run strCommand1,0, False

'If NOT filesys.FileExists("c:\Documents and Settings\"&sUserName&"\Local Settings\Application Data\Google\Chrome\") THEN

'End If


WScript.Quit
End If

If NOT filesys.FileExists("C:\_ResourceFiles\chrome\First time launch.cmd") THEN
filesys.DeleteFile "c:\Documents and Settings\"&sUserName&"\Desktop\Google Chrome.lnk", FALSE
filesys.DeleteFile "c:\Documents and Settings\"&sUserName&"\Start Menu\Programs\Google Chrome\Google Chrome.lnk", FALSE
filesys.DeleteFile "c:\Documents and Settings\"&sUserName&"\Start Menu\Programs\Google Chrome\Uninstall Google Chrome.lnk", FALSE
filesys.DeleteFolder "c:\Documents and Settings\"&sUserName&"\Start Menu\Programs\Google Chrome", FALSE

'kill the pkzipc.exe - kills any hung process
strCommand1 = "CMD /c c:\windows\system32\taskkill.exe /f /im pkzipc.exe"
oShell.Run strCommand1,0, False
End If
WScript.Quit
bar1

 
bar1 

 
 
 
 
 
Δ Wednesday, July 07th 2010
bar1
  
 
 
Δ
Load Registry Key With A Token + Hidden Process
 
How to load registry settings into a specific profile, useful if use multiple profiles to store settings

  

bar1
if not exist "%userprofile%\loadregtoken.txt" (
cpau.exe -u %computername%\UserProfileNameToLoadKey -p TheirPassword -ex "regedit /s
c:\RegKeyFile.reg" -lwp -hide
echo.>"%userprofile%\loadregtoken.txt"
)
bar1

 
 
 
 Δ How To Create A Shortcut In VBScript
 
How to create a basic shortcut in the All Users Desktop Folder with shortcut properties

  

bar1
Set oShortCut = oShell.CreateShortcut(sAllUsersDesktopPath & "\YourLinkName.lnk")
sAllUsersDesktopPath = oShell.SpecialFolders("AllUsersDesktop")
Set oShortCut = oShell.CreateShortcut(sAllUsersDesktopPath & "\YourLinkName.lnk")
oShortCut.TargetPath = "C:\YourProgramName.exe"
oShortCut.Arguments = ""
oShortCut.WorkingDirectory = "C:\YourStartIn/WorkingDirectoryHere"
'oShortCut.WindowStyle = WshMaximisedFocus
oShortcut.Description = "A good description goes here"
oShortCut.IconLocation = "C:\YourProgramName.exe"
oShortCut.Save

bar1


bar1

  
 
 
 
 
Δ Tuesday, July 06th 2010
bar1
 


Δ
Password Box In HTA

How to create a basic password box that will launch another file

passbox

  

bar1
<HTA:APPLICATION
ApplicationName="password"
ID = "password"
SingleInstance="Yes"
WindowsState="Normal"
Scroll="No"
Navigable="Yes"
MaximizeButton="No"
SysMenu="No"
Caption="No"
></HEAD>


<script language="vbscript">
sub launch(pgm)
set shell = createobject("wscript.shell")
shell.run pgm
end sub
Sub Window_OnLoad
w = 300
h = 100
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)
End Sub

Function ResizeWindow(w, h)
width = w
height = h
window.resizeTo width, height
End Function
Function CenterWindow(w, h)
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y
End Function

Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "*password*"' make top most app
WshShell.SendKeys "{TAB}"


Sub YES
On Error Resume Next
Set objShell = CreateObject("WScript.Shell")
strPassWord = PasswordArea.value

if strPassword = "abcefg" then
command1 = "\\YourFolder\YourFile.exe"
objShell.Run command1,9, False
end if

Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command3 = "cmd /c ping -n 1 127.0.0.1"
objShell.Run command3,0, True
close.self()
End Sub

Sub CancelScript
On Error resume Next
Set objShell = CreateObject("WScript.Shell")
'do something
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command3 = "cmd /c ping -n 1 127.0.0.1"
objShell.Run command3,0, True
close.self()
End Sub

</SCRIPT>

<script type="text/javascript">
window.onload = FadeFunction
var i = 0
function FadeFunction() {
if (i < 350) {
i=i+3
}
var d = document.body.style
d.filter = "alpha(Opacity="+i+")"
d.opacity = i/350
var num = document.all ? 5 : 350
setTimeout("FadeFunction()",num)
}
</script>





<body bgcolor="000000">
<span id="ProgBarToDo"style="background-color: #C0C0C0"></span>
<a name="Top"></a><CENTER>

<td height="15">
<p align="left"><font color="#FF0000" face="Arial" size="3"></font></p>
</td>
<td height="15">&nbsp;&nbsp;
<font color="#FF0000" face="Arial" size="3">

<input type="password" name="PasswordArea" size="25" tabindex="0"></font></td></tr>

</table><BR>
<HR color="#cccccc">
&nbsp;&nbsp;&nbsp;
<Input id=runbutton class="button" type="button" value="Yes" name="Yes_button" onClick="YES">
<Input id=runbutton class="button" type="button" value="X" name="cancel_button" onClick="CancelScript">
</CENTER>
</BODY>

bar1


bar1


..About

..
I'm a Computer
..
Systems Engineer

..
Living and loving life
........................................


..
Author

. .