Category Archives: script

bat messagebox / jscript embedded in bat

@if (@x)==(@y) @end /***** jscript comment ******
	@echo off

	cscript //E:JScript //nologo "%~f0" "%~nx0" %*
	exit /b 0
@if (@x)==(@y) @end ******  end comment *********/

/*
Value	Button
0	OK
1	OK, Cancel
2	Abort, Ignore, Retry
3	Yes, No, Cancel
4	Yes, No
5	Retry, Cancel

Value	Icon
0	No Icon
16	Critical
32	Question
48	Exclamation
64	Information
*/

var icon = 64;
var button = 0;
var title = "Sample Title";
var message = "Sample Message";
var timeout = 30;

var pressed_message = "button pressed";
var timeout_message = "timedout";


function runPopup(){
	var wshShell = WScript.CreateObject("WScript.Shell");
	var btn = wshShell.Popup(message, timeout, title, button + icon + 0x10000);

/*
Value	Return Code
1	OK
2	Cancel
3	Abort
4	Retry
5	Ignore
6	Yes
7	No
-1	None, message box was dismissed automatically (timeout)
*/
	switch(btn) {
		// button pressed.
		case 1:
			WScript.Echo(pressed_message);
			break;

		// Timed out.
		case -1:
		   WScript.Echo(timeout_message);
		   break;
	}
}

runPopup();

vbs http download

Dim Hostname, fso, CurrentDirectory
Set wshShell = Wscript.CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

CurrentDirectory = fso.GetAbsolutePathName(".")

Hostname = wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")

WScript.Echo "HOSTNAME: " & Hostname

HTTPDownload "http://example.com/" & Hostname & ".txt", CurrentDirectory

Sub HTTPDownload(myURL, myPath)
	' Standard housekeeping
	Dim i, objFile, objFSO, objHTTP, strFile
	Const ForReading = 1, ForWriting = 2, ForAppending = 8

	' Create a File System Object
	Set objFSO = CreateObject("Scripting.FileSystemObject")

	' Check if the specified target file or folder exists,
	' and build the fully qualified path of the target file
	If objFSO.FolderExists(myPath) Then
		strFile = objFSO.BuildPath(myPath, Mid(myURL, InStrRev(myURL, "/") + 1))
	ElseIf objFSO.FolderExists(Left(myPath, InStrRev(myPath, "\") - 1)) Then
		strFile = myPath
	Else
		WScript.Echo "ERROR: Target folder not found."
		Exit Sub
	End If

	' Create or open the target file
	Set objFile = objFSO.OpenTextFile(strFile, ForWriting, True)

	' Create an HTTP object
	Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

	' Download the specified URL
	objHTTP.Open "GET", myURL, False
	objHTTP.Send

	' Write the downloaded byte stream to the target file
	For i = 1 To LenB(objHTTP.ResponseBody)
		objFile.Write Chr(AscB(MidB(objHTTP.ResponseBody, i, 1)))
	Next

	' Close the target file
	objFile.Close()
End Sub

install script

For Ubuntu/Debian

#!/bin/bash

#tools
PACKAGES=" pdftk "                              # pdf console tools like pdf merging
PACKAGES="$PACKAGES wine"
PACKAGES="$PACKAGES gnuplot"
PACKAGES="$PACKAGES qalculate-gtk"              # advanced simple calculator app
PACKAGES="$PACKAGES pdf-presenter-console"      # console tool for presentations with pdf files
PACKAGES="$PACKAGES stellarium"                 # planetarium software
PACKAGES="$PACKAGES kalzium"                    # kalzium is a PSE software
PACKAGES="$PACKAGES gthumb"                     # gthumb is a picture viewer
PACKAGES="$PACKAGES htop"                       # htop is a more sophisticated version of top
PACKAGES="$PACKAGES basket"                     # note application
PACKAGES="$PACKAGES vpnc"                       # console based VPNC client

# media tools
PACKAGES="$PACKAGES gimp"                       # image editor
PACKAGES="$PACKAGES inkscape"                   # image editor for fast creating vector graphics

PACKAGES="$PACKAGES audacity"                   # audio editor
PACKAGES="$PACKAGES acroread"                   # adobe acrobat reader
PACKAGES="$PACKAGES skype"
PACKAGES="$PACKAGES vlc"                        # vlc media player

# network tools
PACKAGES="$PACKAGES filezilla"                  # tool for ftp/sftp transfers

PACKAGES="$PACKAGES gs gv"                      # ghostscript / view (? to check)
PAKCAGES="$PACKAGES rar"

# network essentials
PACKAGES="$PACKAGES pidgin pidgin-otr thunderbird firefox"
# editors
PACKAGES="$PACKAGES gedit"                      # multi purpose GUI editor
PACKAGES="$PACKAGES texstudio"                  # for latex
PACKAGES="$PACKAGES vim"                        # vi console based editor with several extensions

# java stuff
PACKAGES="$PACKAGES eclipse"                    # IDE will also install current java version

# c++ stuff
PACKAGES="$PACKAGES build-essential gcc"
PACKAGES="$PACKAGES gdb"                        # debugger
PACKAGES="$PACKAGES codeblocks"                 # IDE

# doxygen for documentation of c++ projects (note don't know why graphviz appears here)
PACKAGES="$PACKAGES doxygen doxygen-doc doxygen-gui graphviz doxygen-latex"

# SDL for Games and also DEV for graphic programming
PACKAGES="$PACKAGES libsdl-gfx1.2-4 libsdl-gfx1.2-dev libsdl1.2-dev libsdl1.2debian"

# the boost library dev package -> large c++ libary
PACKAGES="$PACKAGES libboost-all-dev"

# qt packages
PACKAGES="$PACKAGES libqt4-core libqt4-dev qt4-dev-tools qt4-designer qt4-doc"

# games
PACKAGES="$PACKAGES sauerbraten libopenal1 openarena"

# latex
PACKAGES="$PACKAGES texlive-latex3 texlive-science texlive-extra"

# python
PACKAGES="$PACKAGES python"
PACKAGES="$PACKAGES python-pip"                 # command line tool for installing python packages

# scipy packages
PACKAGES="$PACKAGES python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose"

# if the user is not root finish
if [ "$(whoami)" != "root" ];
then
    echo "you must be root!"
    echo "please restart as root"
    exit
fi

# update && upgrade before installing packages
apt-get update
apt-get upgrade -y

#Installing all Ubuntu deb packages
for P in $PACKAGES; do
    echo Installing $P
    apt-get install $P -y
    echo $P ready
done

For arch

#!/bin/bash

###tools
## Pacman
pacmanpacs="wine"                               # WINE Is Not an Emulator
pacmanpacs="$pacmanpacs gnuplot"
pacmanpacs="$pacmanpacs qalculate-gtk"          # advanced simple calculator app
pacmanpacs="$pacmanpacs stellarium"             # planetarium software
pacmanpacs="$pacmanpacs kdeedu-kalzium"         # kalzium is a PSE software
pacmanpacs="$pacmanpacs gthumb"                 # gthumb is a picture viewer
pacmanpacs="$pacmanpacs htop"                   # htop is a more sophisticated version of top
pacmanpacs="$pacmanpacs basket"                 # note application
pacmanpacs="$pacmanpacs openconnect vpnc"       # console based VPN clients (Cisco compatible)
pacmanpacs="$pacmanpacs openssh sshfs"          # SSH tools
pacmanpacs="$pacmanpacs gv"                     # gostscript / view (? to check)
pacmanpacs="$pacmanpacs unrar"

## Yaourt
yaourtpacs=" pdftk"                             # pdf console tools like pdf merging
yaourtpacs="$yaourtpacs pdf_presenter_console"  # console tool for presentations with pdf files

### media tools
## Pacman
pacmanpacs="$pacmanpacs inkscape"               # image editor for fast creating vector graphics
pacmanpacs="$pacmanpacs audacity"               # audio editor
pacmanpacs="$pacmanpacs skype"
pacmanpacs="$pacmanpacs smplayer vlc xbmc"      # media player

## Yaourt
yaourtpacs="$yaourtpacs acroread"               # adobe acrobat reader

### network tools
## Pacman
pacmanpacs="$pacmanpacs filezilla"              # tool for ftp/sftp transfers
pacmanpacs="$pacmanpacs pidgin pidgin-otr"      # Pidgin
pacmanpacs="$pacmanpacs thunderbird firefox"    # Mozilla things

## Yaourt
yaourtpacs="$yaourtpacs dropbox"                # Cloud Tool

### editors
## Pacman
pacmanpacs="$pacmanpacs vim"                    # vi console based editor with several extensions

## Yaourt
yaourtpacs="$yaourtpacs texstudio"              # for latex

### java stuff
## Pacman
pacmanpacs="$pacmanpacs subversion eclipse"     # IDE will also install current java version
pacremove="jdk7-openjdk"                        # Will be removed

## Yaourt
yaourtpacs="$yaourtpacs jdk7"                   # Oracle JDK

### c++ stuff
## Pacman
pacmanpacs="$pacmanpacs gdb"                    # debugger
pacmanpacs="$pacmanpacs eclipse-cdt codeblocks" # IDE
pacmanpacs="$pacmanpacs doxygen doxygen-docs graphviz"    # doxygen for documentation of c++ projects (note don't know why graphviz appears here)
pacmanpacs="$pacmanpacs sdl sdl_gfx sdl_image " # SDL for Games and also DEV for graphic programming
pacmanpacs="$pacmanpacs sdl_mixer sdl_net sdl_ttf smpeg"
pacmanpacs="$pacmanpacs sdl2 sdl2_gfx sdl2_image"
pacmanpacs="$pacmanpacs sdl2_mixer sdl2_net sdl2_ttf smpeg2"
pacmanpacs="$pacmanpacs boost boost-libs"       # the boost library dev package ->; large c++ libary
pacmanpacs="$pacmanpacs qt qtcreator"           # qt packages

### games
## Pacman
pacmanpacs="$pacmanpacs sauerbraten 0ad"

## Yaourt
yaourtpacs="$yaourtpacs openarena 7kaa"

### latex
## Pacman
pacmanpacs="$pacmanpacs texlive-most"

### python
## Pacman
pacmanpacs="$pacmanpacs python-pip"             # command line tool for installing python packages
pacmanpacs="$pacmanpacs python-scipy python-matplotlib"   # scipy packages
pacmanpacs="$pacmanpacs python-sympy python-nose"

## Yaourt
yaourtpacs="$yaourtpacs python-pandas"

# if the user is not root finish
if [ "$(whoami)" != "root" ];
then
    echo "you must be root!"
    echo "please restart as root"
    exit
fi

# update and upgrade the system
pacman -Syu --noconfirm

# remove unneeded packages
pacman -Rcdd $pacremove --noconfirm

# add AUR packages
yaourt -S $yaourtpacs --noconfirm

# add normal packages
pacman -S $pacmanpacs --noconfirm