In the void is virtue, and no evil. Wisdom has existance, principle has existance, the Way has existance, spirit is nothingness.
Image
Search This Blog
Monday, December 01, 2014
Stream webcam with sound
cvlc v4l2:///dev/video1 :v4l2-standard= :input-slave=alsa://hw:0,0 :live-caching=300 :sout=#"transcode{vcodec=mp4v,vb=256,scale=Auto,acodec=mp4a,ab=48,channels=1,samplerate=8000}:http{mux=asf,dst=:8080/}" :sout-keep
Tuesday, November 04, 2014
Windows Shell for TS - without Domain Controller
On the RD Session Host Configuration ,the following (compiled as c:\windows\tssession.exe) script is executed as initial shell:
;(c)2014 sorinakis@g**il.com
;msgbox, Username: %A_UserName%
AuthUsers = Administrator|administrator
Loop Parse, AuthUsers, |
{
ifEqual, A_LoopField, %A_Username%
{
Sleep, 500
Run, explorer.exe
;MsgBox EXPLORER Executed.
GoTo, End
}
else
{
;MsgBox In the ELSE branch.
Sleep, 500
Run, D:\Partages\apps\LCM\Bin\wrun32.exe -ws -c D:\Partages\apps\LCM\etc\CBLCONFI-RZ_APP.ini utmenu
Sleep 500
WinMaximize, ahk_class AcucobolWClass
IfWinExist, Cie(01)
{
WinMaximize, Cie(01)
Sleep, 500
WinWaitClose, Cie(01)
Sleep, 500
Run, shutdown /l
}
Return
}
}
End:
Sleep, 100
;MsgBox At the END.
;(c)2014 sorinakis@g**il.com
;msgbox, Username: %A_UserName%
AuthUsers = Administrator|administrator
Loop Parse, AuthUsers, |
{
ifEqual, A_LoopField, %A_Username%
{
Sleep, 500
Run, explorer.exe
;MsgBox EXPLORER Executed.
GoTo, End
}
else
{
;MsgBox In the ELSE branch.
Sleep, 500
Run, D:\Partages\apps\LCM\Bin\wrun32.exe -ws -c D:\Partages\apps\LCM\etc\CBLCONFI-RZ_APP.ini utmenu
Sleep 500
WinMaximize, ahk_class AcucobolWClass
IfWinExist, Cie(01)
{
WinMaximize, Cie(01)
Sleep, 500
WinWaitClose, Cie(01)
Sleep, 500
Run, shutdown /l
}
Return
}
}
End:
Sleep, 100
;MsgBox At the END.
Thursday, October 16, 2014
Friday, October 03, 2014
SSH BruteForce Attacks are back
I've put back the little iptables rule:
-N SSHBRUTE
-A INPUT -i eth1 -p tcp -m tcp --dport 22 -m state --state NEW -m recent -j SSHBRUTE
-A SSHBRUTE -m recent --set --name BRUTESSH --rsource
-A SSHBRUTE -m recent --rcheck --seconds 60 --hitcount 5 --rttl --name BRUTESSH --rsource -j \ REJECT --reject-with tcp-reset
-A SSHBRUTE -m recent --rcheck --seconds 60 --hitcount 4 --rttl --name BRUTESSH --rsource -j \ LOG --log-prefix "Brute Force SSH Drop"
-A SSHBRUTE -m recent --update --seconds 60 --hitcount 4 --rttl --name BRUTESSH --rsource -j \ REJECT --reject-with tcp-reset
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-N SSHBRUTE
-A INPUT -i eth1 -p tcp -m tcp --dport 22 -m state --state NEW -m recent -j SSHBRUTE
-A SSHBRUTE -m recent --set --name BRUTESSH --rsource
-A SSHBRUTE -m recent --rcheck --seconds 60 --hitcount 5 --rttl --name BRUTESSH --rsource -j \ REJECT --reject-with tcp-reset
-A SSHBRUTE -m recent --rcheck --seconds 60 --hitcount 4 --rttl --name BRUTESSH --rsource -j \ LOG --log-prefix "Brute Force SSH Drop"
-A SSHBRUTE -m recent --update --seconds 60 --hitcount 4 --rttl --name BRUTESSH --rsource -j \ REJECT --reject-with tcp-reset
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Tuesday, September 02, 2014
A simple script to import .pst in thunderbird
#!/bin/bash
#
#(c)2014 sorinakis@g*il.com
if [ "$(whereis readpste | cut -d: -f2)" = "" ]; then.
echo "Sending you to download readpst"
kdialog --warningcontinuecancel "Go to http://www.five-ten-sg.com/libpst/ to download, then compile and install libpst
Once libpst is installed please re-execute this script.
If readpst is installed, but not in path, you have to comment the first section of $0" --continue-label "Go to site"
if [ ! $? = 0 ]; then
echo "Cancel Pressed. Exit"
exit 2
fi
xdg-open http://www.five-ten-sg.com/libpst/
exit 0
fi
# Prepare location
wrkfld=$TMP/outlook$$
export $(dbus-launch)
mkdir $wrkfld
# Convert pst
readpst -o $wrkfld -r "`kdialog --getopenfilename ~ '*.pst' 2>/dev/null`"
# Rename folder so thunderbird understands
find $wrkfld -type d | tac | grep -v '^$wrkfld$' | xargs -d '\n' -I{} mv {} {}.sbd
find $wrkfld.sbd -name mbox -type f | xargs -d '\n' -I{} echo '"{}" "{}"' | sed -e 's/\.sbd\/mbox"$/"/' | xargs -L 1 mv
#Cleanup empty folders
find $wrkfld.sbd -empty -type d | xargs -d '\n' rmdir
kdialog --msgbox "Conversion Done! Please create a subfolder in your Thunderbird's Local Folders,.
then manuallly move $wrkfld.sdb into ~/.thunderbird/[profile]/Mail/Local Folders/[new folder]"
#
#(c)2014 sorinakis@g*il.com
if [ "$(whereis readpste | cut -d: -f2)" = "" ]; then.
echo "Sending you to download readpst"
kdialog --warningcontinuecancel "Go to http://www.five-ten-sg.com/libpst/ to download, then compile and install libpst
Once libpst is installed please re-execute this script.
If readpst is installed, but not in path, you have to comment the first section of $0" --continue-label "Go to site"
if [ ! $? = 0 ]; then
echo "Cancel Pressed. Exit"
exit 2
fi
xdg-open http://www.five-ten-sg.com/libpst/
exit 0
fi
# Prepare location
wrkfld=$TMP/outlook$$
export $(dbus-launch)
mkdir $wrkfld
# Convert pst
readpst -o $wrkfld -r "`kdialog --getopenfilename ~ '*.pst' 2>/dev/null`"
# Rename folder so thunderbird understands
find $wrkfld -type d | tac | grep -v '^$wrkfld$' | xargs -d '\n' -I{} mv {} {}.sbd
find $wrkfld.sbd -name mbox -type f | xargs -d '\n' -I{} echo '"{}" "{}"' | sed -e 's/\.sbd\/mbox"$/"/' | xargs -L 1 mv
#Cleanup empty folders
find $wrkfld.sbd -empty -type d | xargs -d '\n' rmdir
kdialog --msgbox "Conversion Done! Please create a subfolder in your Thunderbird's Local Folders,.
then manuallly move $wrkfld.sdb into ~/.thunderbird/[profile]/Mail/Local Folders/[new folder]"
Sunday, August 10, 2014
Tune UP (in fact down) Windows 2008 R2
sssc config lanmanworkstation depend= bowser/mrxsmb10/nsi
sc config mrxsmb20 start= disabled
netsh int tcp set global rss=disabled
netsh int tcp set global chimney=disabled
netsh int tcp set global autotuninglevel=disabled
netsh int ip set global taskoffload=disablednetsh int tcp set global autotuninglevel=disablednetsh int tcp set global ecncapability=disablednetsh int tcp set global timestamps=disablednetsh advf set allp state off
:: reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v DisableTaskOffload /t REG_DWORD /d "1" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters" /v DisableBandwidthThrottling /t REG_DWORD /d "1" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp" /v TcpAutotuning /t REG_DWORD /d "0" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v TcpAutotuning /t REG_DWORD /d "0" /f
reg add "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings" /v TcpAutotuning /t REG_DWORD /d "0" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v EnableTCPA /t REG_DWORD /d "0" /f
sc config mrxsmb20 start= disabled
netsh int tcp set global rss=disabled
netsh int tcp set global chimney=disabled
netsh int tcp set global autotuninglevel=disabled
netsh int ip set global taskoffload=disablednetsh int tcp set global autotuninglevel=disablednetsh int tcp set global ecncapability=disablednetsh int tcp set global timestamps=disablednetsh advf set allp state off
:: reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v DisableTaskOffload /t REG_DWORD /d "1" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters" /v DisableBandwidthThrottling /t REG_DWORD /d "1" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp" /v TcpAutotuning /t REG_DWORD /d "0" /f
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" /v TcpAutotuning /t REG_DWORD /d "0" /f
reg add "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings" /v TcpAutotuning /t REG_DWORD /d "0" /f
reg add "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" /v EnableTCPA /t REG_DWORD /d "0" /f
Friday, July 11, 2014
Watermark Printer
This is a very crude version of a "Watermark Printer" - it prints on a "preprinted paper" (e.g. something containing the company logo)
@echo off
:: ------------------------------------------------------------------
:: install redmon in %userprofile%\appdata\redmon
:: put this script in %userprofile%\appdata\redmon\email.bat
:: create new printer with port RPT1:
:: configure port redirect to %userprofile%\appdata\redmon\redrun.exe
:: port arguments %userprofile%\appdata\redmon\email.bat %%1
:: ------------------------------------------------------------------
:: Ghostscript configuraton
set GS_INSTALL="%userprofile%\appdata\redmon\gs"
set GS_VERSION=8.63
:: LibTIFF configuraton
set LIBTIFF_INSTALL=%userprofile%\appdata\redmon\GnuWin32
:: PDF viewer configuraton (no need to set, if PDF is a registered file type)
set PDF_READER=
:: Watermark background config
set BACKGROUND="%userprofile%\appdata\redmon\\Watermark.pdf"
:: PDFTK location
set PDFTK="%userprofile%\appdata\redmon\"
:: ------------------------------------------------------------------
:: temporary PDF directory
set PDF_DIR=%TEMP%\1
:: delete old temporary PDF directories if required
for /d %%D in ("%TEMP%\1\") do if not "%%D"=="%TEMP%\1\" rd /s /q "%%D"
:: create if required
if not exist "%PDF_DIR%" md "%PDF_DIR%"
echo myass > %PDF_DIR%\blah
:: check if file is given
if not "%~1" == "" goto CHECK_FOUND
echo ERROR: No file name given!
goto END
::----------
:CHECK_FOUND
:: check for file existence
if exist "%*" goto SET_FNE
echo ERROR: File "%*" not found!
goto END
::------
:SET_FNE
:: set input file, name and extension
call :set_input_file_name_ext "%*"
:: check file type
if "%INPUT_EXT%" == "" set INPUT_NAME=%~n1.ps
if "%INPUT_EXT%" == "" set INPUT_EXT=.ps
if "%INPUT_EXT%" == ".ps" goto PROCESS_PS
if "%INPUT_EXT%" == ".tiff" goto PROCESS_TIFF
if "%INPUT_EXT%" == ".tif" goto PROCESS_TIFF
if "%INPUT_EXT%" == ".pdf" goto PROCESS_PDF
echo ERROR: File type "%INPUT_EXT%" not supported!
goto END
:: --------
:PROCESS_PS
:: set file names
set PS_FILE=%INPUT_FILE%
set PDF_FILE=%PDF_DIR%\%INPUT_NAME%.pdf
:: convert to PDF
"%GS_INSTALL%\gs%GS_VERSION%\bin\gswin32c.exe" -dSAFER -dNumRenderingThreads#%NUMBER_OF_PROCESSORS% -sDEVICE#pdfwrite -o "%PDF_FILE%" -c .setpdfwrite -f "%PS_FILE%"
goto DISPLAY
:: ----------
:PROCESS_TIFF
:: set file names
set TIFF_FILE=%INPUT_FILE%
set PDF_FILE=%PDF_DIR%\%INPUT_NAME%.pdf
:: convert to PDF
"%LIBTIFF_INSTALL%\bin\tiff2pdf.exe" -o "%PDF_FILE%" -f "%TIFF_FILE%"
goto DISPLAY
:: ---------
:PROCESS_PDF
:: set file name
set PDF_FILE=%INPUT_FILE%
::
:: ------------------------------------------------------------------
:DISPLAY
:: open PDF file in reader
:: start /b "%PDF_READER%" "%PDF_FILE%"
::
:: apply background
%PDFTK%\pdftk.exe "%PDF_FILE%" background %BACKGROUND% output "%PDF_DIR%\output.pdf"
:: call OUTLOOK - ugly for the moment
"C:\Program Files (x86)\Microsoft Office\OFFICE14\OUTLOOK.EXE" /a "%PDF_DIR%\output.pdf"
:: ------------------------------------------------------------------
:END
exit
::
:: ------------------------------------------------------------------
:: Subroutine: set_input_file_name_ext
:: Arguments: %1 = "path/name.ext"
:: Purpose: set environment vars to input file, name and extension
:: ------------------------------------------------------------------
:set_input_file_name_ext
set INPUT_FILE=%~1
set INPUT_NAME=%~n1
set INPUT_EXT=%~x1
goto :eof
:: ------------------------------------------------------------------
@echo off
:: ------------------------------------------------------------------
:: install redmon in %userprofile%\appdata\redmon
:: put this script in %userprofile%\appdata\redmon\email.bat
:: create new printer with port RPT1:
:: configure port redirect to %userprofile%\appdata\redmon\redrun.exe
:: port arguments %userprofile%\appdata\redmon\email.bat %%1
:: ------------------------------------------------------------------
:: Ghostscript configuraton
set GS_INSTALL="%userprofile%\appdata\redmon\gs"
set GS_VERSION=8.63
:: LibTIFF configuraton
set LIBTIFF_INSTALL=%userprofile%\appdata\redmon\GnuWin32
:: PDF viewer configuraton (no need to set, if PDF is a registered file type)
set PDF_READER=
:: Watermark background config
set BACKGROUND="%userprofile%\appdata\redmon\\Watermark.pdf"
:: PDFTK location
set PDFTK="%userprofile%\appdata\redmon\"
:: ------------------------------------------------------------------
:: temporary PDF directory
set PDF_DIR=%TEMP%\1
:: delete old temporary PDF directories if required
for /d %%D in ("%TEMP%\1\") do if not "%%D"=="%TEMP%\1\" rd /s /q "%%D"
:: create if required
if not exist "%PDF_DIR%" md "%PDF_DIR%"
echo myass > %PDF_DIR%\blah
:: check if file is given
if not "%~1" == "" goto CHECK_FOUND
echo ERROR: No file name given!
goto END
::----------
:CHECK_FOUND
:: check for file existence
if exist "%*" goto SET_FNE
echo ERROR: File "%*" not found!
goto END
::------
:SET_FNE
:: set input file, name and extension
call :set_input_file_name_ext "%*"
:: check file type
if "%INPUT_EXT%" == "" set INPUT_NAME=%~n1.ps
if "%INPUT_EXT%" == "" set INPUT_EXT=.ps
if "%INPUT_EXT%" == ".ps" goto PROCESS_PS
if "%INPUT_EXT%" == ".tiff" goto PROCESS_TIFF
if "%INPUT_EXT%" == ".tif" goto PROCESS_TIFF
if "%INPUT_EXT%" == ".pdf" goto PROCESS_PDF
echo ERROR: File type "%INPUT_EXT%" not supported!
goto END
:: --------
:PROCESS_PS
:: set file names
set PS_FILE=%INPUT_FILE%
set PDF_FILE=%PDF_DIR%\%INPUT_NAME%.pdf
:: convert to PDF
"%GS_INSTALL%\gs%GS_VERSION%\bin\gswin32c.exe" -dSAFER -dNumRenderingThreads#%NUMBER_OF_PROCESSORS% -sDEVICE#pdfwrite -o "%PDF_FILE%" -c .setpdfwrite -f "%PS_FILE%"
goto DISPLAY
:: ----------
:PROCESS_TIFF
:: set file names
set TIFF_FILE=%INPUT_FILE%
set PDF_FILE=%PDF_DIR%\%INPUT_NAME%.pdf
:: convert to PDF
"%LIBTIFF_INSTALL%\bin\tiff2pdf.exe" -o "%PDF_FILE%" -f "%TIFF_FILE%"
goto DISPLAY
:: ---------
:PROCESS_PDF
:: set file name
set PDF_FILE=%INPUT_FILE%
::
:: ------------------------------------------------------------------
:DISPLAY
:: open PDF file in reader
:: start /b "%PDF_READER%" "%PDF_FILE%"
::
:: apply background
%PDFTK%\pdftk.exe "%PDF_FILE%" background %BACKGROUND% output "%PDF_DIR%\output.pdf"
:: call OUTLOOK - ugly for the moment
"C:\Program Files (x86)\Microsoft Office\OFFICE14\OUTLOOK.EXE" /a "%PDF_DIR%\output.pdf"
:: ------------------------------------------------------------------
:END
exit
::
:: ------------------------------------------------------------------
:: Subroutine: set_input_file_name_ext
:: Arguments: %1 = "path/name.ext"
:: Purpose: set environment vars to input file, name and extension
:: ------------------------------------------------------------------
:set_input_file_name_ext
set INPUT_FILE=%~1
set INPUT_NAME=%~n1
set INPUT_EXT=%~x1
goto :eof
:: ------------------------------------------------------------------
Thursday, June 05, 2014
Allow login only if the member of a certain OU comes from a certain IP subnet
@echo off
:: (c)2014 sorinakis@g*il.com
setlocal enableextensions enabledelayedexpansion
set config=c:\pair.txt
:: find the primary OU that user belongs to
for /F "tokens=3 delims=/,CN=" %%n in ('"gpresult /R | findstr CN | findstr /I %username%"') do (
set myou=%%n
)
:: echo myou is: !myou!
:: find the client subnet (need gettscip.exe from www.ctrl-alt-del.com.au in the path somewhere)
for /F "tokens=2 delims=/: " %%f in ('gettscip.exe') do (
for /F "tokens=1-3 delims=/." %%g in ('echo %%f') do set mynet=%%g.%%h.%%i
)
:: echo mynet is: !mynet!
:: read the config file containing the pair IP_subnet/Organisational_Unit (or group)
:: the pair have to be separated by a space, ex: '192.168.1 Users' comments start with ;
for /F "eol=; tokens=1,2 delims=/ " %%l in ('type !config!') do (
set net=%%l
:: set group=%%m
set ou=%%m
:: find if the user belongs to a group
rem for /f %%f in ('"net user /domain %username% | findstr /i %group%"') do set /a ingroup=yes
:: if the two pairs are identical, the user can login from that subnet
if "!net!"=="!mynet!" (
:: if "!ingroup!"=="yes" (
if /I "!ou!"=="!myou!" (
set canrun=yes
)
)
)
::echo canrun: !canrun!
:: if the user can't login let him know, then end the session
if NOT "!canrun!"=="yes" (
echo Sorry %username%, "!myou!" are NOT ALLOWED to login from !mynet!.0/24
msg %username% Sorry, %username% is NOT ALLOWED to login from this location.
shutdown /l
)
:: Cleanup variables at end
endlocal
:: (c)2014 sorinakis@g*il.com
setlocal enableextensions enabledelayedexpansion
set config=c:\pair.txt
:: find the primary OU that user belongs to
for /F "tokens=3 delims=/,CN=" %%n in ('"gpresult /R | findstr CN | findstr /I %username%"') do (
set myou=%%n
)
:: echo myou is: !myou!
:: find the client subnet (need gettscip.exe from www.ctrl-alt-del.com.au in the path somewhere)
for /F "tokens=2 delims=/: " %%f in ('gettscip.exe') do (
for /F "tokens=1-3 delims=/." %%g in ('echo %%f') do set mynet=%%g.%%h.%%i
)
:: echo mynet is: !mynet!
:: read the config file containing the pair IP_subnet/Organisational_Unit (or group)
:: the pair have to be separated by a space, ex: '192.168.1 Users' comments start with ;
for /F "eol=; tokens=1,2 delims=/ " %%l in ('type !config!') do (
set net=%%l
:: set group=%%m
set ou=%%m
:: find if the user belongs to a group
rem for /f %%f in ('"net user /domain %username% | findstr /i %group%"') do set /a ingroup=yes
:: if the two pairs are identical, the user can login from that subnet
if "!net!"=="!mynet!" (
:: if "!ingroup!"=="yes" (
if /I "!ou!"=="!myou!" (
set canrun=yes
)
)
)
::echo canrun: !canrun!
:: if the user can't login let him know, then end the session
if NOT "!canrun!"=="yes" (
echo Sorry %username%, "!myou!" are NOT ALLOWED to login from !mynet!.0/24
msg %username% Sorry, %username% is NOT ALLOWED to login from this location.
shutdown /l
)
:: Cleanup variables at end
endlocal
Tuesday, May 06, 2014
Delete old printers ond add new ones - second version
This version keeps track of the default printer :)
' s@to**.guru - Jan 08 2015 Replace the default Printer
'********************************************************************************************************************
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
'Set wmiLocator = CreateObject("WbemScripting.SWbemLocator")
'Set wmiNameSpace = wmiLocator.ConnectServer(objNetwork.ComputerName, "root\default")
'Set objRegistry = wmiNameSpace.Get("StdRegProv")
'strComputer = "."
'Const HKEY_CLASSES_ROOT = &H80000000
'Const HKEY_CURRENT_USER = &H80000001
'Const HKEY_LOCAL_MACHINE = &H80000002
'Const HKEY_USERS = &H80000003
userprrf = objShell.Environment("PROCESS")("UserProfile")
lockfile = "\prinstalled"
oldlockfile = "\printersinstalled"
strnewSrv = "\\2K12SRV\"
strOldSrv = "\\critesdc\"
arrPrinters = Array("HP Color LaserJet 4700 PCL 5c","HP Color LaserJet 4700 PCL 5c Sales","HP LaserJet 4100 Series PCL6 Sales","HP LaserJet 4250 PCL6","HP Laserjet 5100tn","Xerox WorkCentre 5655 PS","Xerox7545 PS")
'********************************************************************************************************************
' If this script was already run at least once for this user, EXIT and don't look back
If (objFSO.FileExists(userprrf & lockfile)) Then
Wscript.Quit
End If
' Delete old lockfile
objFSO.DeleteFile(userprrf & oldlockfile)
'' If we're on the TS server create lockfile and Exit!
'If objNetwork.ComputerName = "2K12TS1" Then
' Set objFile = objFSO.CreateTextFile(userprrf & lockfile, true)
' Set objFile = objFSO.GetFile(userprrf & lockfile)
' objFile.Attributes = 2
' Wscript.Quit
'End if
'********************************************************************************************************************
' Make spooler autostart without waiting
' use Microsoft's way of getting StdRegProv, set_binary is special!
'Set oRegistry = _
' GetObject("Winmgmts:root\default:StdRegProv")
'strPath = "SYSTEM\CurrentControlSet\Services\Spooler"
'uBinary = Array(80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,20,00,64,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00)
'Return = oRegistry.SetBinaryValue(HKEY_LOCAL_MACHINE, _
' strPath, _
' "FailureActions", _
' uBinary)
'oShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Spooler\Start", 2, "REG_DWORD"
'********************************************************************************************************************
' get the default printer
strdefValue = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
strdefPrinter = objShell.RegRead(strdefValue)
strdefPrinter = Split(strdefPrinter, ",")(0)
'wscript.Echo "Actual default printer: " & strdefPrinter
' put the default printer into the lockfile if we want to keep it for historical records
'Set objFile = objFSO.CreateTextFile(userprrf & lockfile)
'objFile.Write strdefPrinter & vbCrLf
'objFile.Close
'********************************************************************************************************************
'Delete old printers using either printui.dll or AddWindowsPrinterConnection
wscript.sleep 100
For Each strPrn in arrPrinters
strPrinter = (strOldSrv & strPrn)
'wscript.echo "removing " & strPrinter
strCmd = "rundll32 printui.dll,PrintUIEntry /dn /n """ & strPrinter & """ /q"
objShell.Run strCmd,,true
' objNetwork.RemoveWindowsPrinterConnection strOldSrv & strPrn
Next
'********************************************************************************************************************
' to make sure all printers are removed, Deletes RegistryKey with all subkeys in Network printers
'sPath = "Printers\Connections"
'lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath)
'Function DeleteRegEntry(sHive, sEnumPath)
' Attempt to delete key. If it fails, start the subkey enumration process.
'lRC = objRegistry.DeleteKey(sHive, sEnumPath)
' The deletion failed, start deleting subkeys.
'If (lRC <> 0) Then
' Subkey Enumerator
'On Error Resume Next
'lRC = objRegistry.EnumKey(HKEY_CURRENT_USER, sEnumPath, sNames)
'For Each sKeyName In sNames
'If Err.Number <> 0 Then Exit For
'lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)
'Next
'On Error Goto 0
' At this point we should have looped through all subkeys, trying to delete the key again.
'lRC = objRegistry.DeleteKey(sHive, sEnumPath)
'End If
'End Function
' Now let's recreate only the "root" Key we deleted before
'objRegistry.CreateKey HKEY_CURRENT_USER,sPath
'********************************************************************************************************************
' we have zero network printers, let`s remove all unused drivers by using Microsoft`s own prndrvr.vbs
' first restart print spooler in order to release open files
'Set objWMIService = GetObject("winmgmts:" _
' & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Set colServiceList = objWMIService.ExecQuery _
' ("Select * from Win32_Service where Name='Spooler'")
'For each objService in colServiceList
' errReturn = objService.StopService()
'Next
'wscript.sleep 1000
'Set colServiceList = objWMIService.ExecQuery _
' ("Select * from Win32_Service where Name='Spooler'")
'For each objService in colServiceList
' errReturn = objService.StartService()
'Next
'oShell.Run "cscript %systemroot%\system32\prndrvr.vbs -x"
'********************************************************************************************************************
'Add new printers using either printui.dll or AddWindowsPrinterConnection
wscript.sleep 100
For Each strPrn in arrPrinters
strPrinter = (strNewSrv & strPrn)
'wscript.echo "installing " & strPrinter
strCmd = "rundll32 printui.dll,PrintUIEntry /in /n """ & strPrinter & """ /u /q /Gw"
objShell.Run strCmd,,true
' objNetwork.AddWindowsPrinterConnection strNewSrv & strPrn
Next
'********************************************************************************************************************
' Try to put back the default printer
'Set objFile = objFSO.OpenTextFile(userprrf & lockfile)
'Do Until objFile.AtEndOfStream
' strNewDefPrinter = objFile.ReadLine
'Loop
'objFile.Close
strNewDefault = (Replace(strdefPrinter,strOldSrv, strNewSrv))
'wscript.Echo "New default printer: " & strNewDefault
strCmd = "rundll32 printui.dll,PrintUIEntry /y /n """ & strrNewDefault & """ /u /q /Gw"
objShell.Run strCmd,,true
'objNetwork.SetDefaultPrinter strNewDefault
'********************************************************************************************************************
' Tell the user to check his default printer
beep = chr(007)
objShell.Run "cmd /c @echo " & beep & beep, 0
'with createobject("wscript.shell")
' .popup "Tous vos imprimantes réseau ont été installés. SVP vérifier et changer votre imprimante DÉFAULT si nécessaire.",30, "Printers Manager"
'end with
'objShell.Exec("control printers")
'********************************************************************************************************************
' We're done, let's leave a hidden file in userprofile, so at next login this script will exit
Set objFile = objFSO.CreateTextFile(userprrf & lockfile, true)
Set objFile = objFSO.GetFile(userprrf & lockfile)
objFile.Attributes = 2
Wscript.Quit
' s@to**.guru - Jan 08 2015 Replace the default Printer
'********************************************************************************************************************
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
'Set wmiLocator = CreateObject("WbemScripting.SWbemLocator")
'Set wmiNameSpace = wmiLocator.ConnectServer(objNetwork.ComputerName, "root\default")
'Set objRegistry = wmiNameSpace.Get("StdRegProv")
'strComputer = "."
'Const HKEY_CLASSES_ROOT = &H80000000
'Const HKEY_CURRENT_USER = &H80000001
'Const HKEY_LOCAL_MACHINE = &H80000002
'Const HKEY_USERS = &H80000003
userprrf = objShell.Environment("PROCESS")("UserProfile")
lockfile = "\prinstalled"
oldlockfile = "\printersinstalled"
strnewSrv = "\\2K12SRV\"
strOldSrv = "\\critesdc\"
arrPrinters = Array("HP Color LaserJet 4700 PCL 5c","HP Color LaserJet 4700 PCL 5c Sales","HP LaserJet 4100 Series PCL6 Sales","HP LaserJet 4250 PCL6","HP Laserjet 5100tn","Xerox WorkCentre 5655 PS","Xerox7545 PS")
'********************************************************************************************************************
' If this script was already run at least once for this user, EXIT and don't look back
If (objFSO.FileExists(userprrf & lockfile)) Then
Wscript.Quit
End If
' Delete old lockfile
objFSO.DeleteFile(userprrf & oldlockfile)
'' If we're on the TS server create lockfile and Exit!
'If objNetwork.ComputerName = "2K12TS1" Then
' Set objFile = objFSO.CreateTextFile(userprrf & lockfile, true)
' Set objFile = objFSO.GetFile(userprrf & lockfile)
' objFile.Attributes = 2
' Wscript.Quit
'End if
'********************************************************************************************************************
' Make spooler autostart without waiting
' use Microsoft's way of getting StdRegProv, set_binary is special!
'Set oRegistry = _
' GetObject("Winmgmts:root\default:StdRegProv")
'strPath = "SYSTEM\CurrentControlSet\Services\Spooler"
'uBinary = Array(80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,20,00,64,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00)
'Return = oRegistry.SetBinaryValue(HKEY_LOCAL_MACHINE, _
' strPath, _
' "FailureActions", _
' uBinary)
'oShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\Services\Spooler\Start", 2, "REG_DWORD"
'********************************************************************************************************************
' get the default printer
strdefValue = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
strdefPrinter = objShell.RegRead(strdefValue)
strdefPrinter = Split(strdefPrinter, ",")(0)
'wscript.Echo "Actual default printer: " & strdefPrinter
' put the default printer into the lockfile if we want to keep it for historical records
'Set objFile = objFSO.CreateTextFile(userprrf & lockfile)
'objFile.Write strdefPrinter & vbCrLf
'objFile.Close
'********************************************************************************************************************
'Delete old printers using either printui.dll or AddWindowsPrinterConnection
wscript.sleep 100
For Each strPrn in arrPrinters
strPrinter = (strOldSrv & strPrn)
'wscript.echo "removing " & strPrinter
strCmd = "rundll32 printui.dll,PrintUIEntry /dn /n """ & strPrinter & """ /q"
objShell.Run strCmd,,true
' objNetwork.RemoveWindowsPrinterConnection strOldSrv & strPrn
Next
'********************************************************************************************************************
' to make sure all printers are removed, Deletes RegistryKey with all subkeys in Network printers
'sPath = "Printers\Connections"
'lRC = DeleteRegEntry(HKEY_CURRENT_USER, sPath)
'Function DeleteRegEntry(sHive, sEnumPath)
' Attempt to delete key. If it fails, start the subkey enumration process.
'lRC = objRegistry.DeleteKey(sHive, sEnumPath)
' The deletion failed, start deleting subkeys.
'If (lRC <> 0) Then
' Subkey Enumerator
'On Error Resume Next
'lRC = objRegistry.EnumKey(HKEY_CURRENT_USER, sEnumPath, sNames)
'For Each sKeyName In sNames
'If Err.Number <> 0 Then Exit For
'lRC = DeleteRegEntry(sHive, sEnumPath & "\" & sKeyName)
'Next
'On Error Goto 0
' At this point we should have looped through all subkeys, trying to delete the key again.
'lRC = objRegistry.DeleteKey(sHive, sEnumPath)
'End If
'End Function
' Now let's recreate only the "root" Key we deleted before
'objRegistry.CreateKey HKEY_CURRENT_USER,sPath
'********************************************************************************************************************
' we have zero network printers, let`s remove all unused drivers by using Microsoft`s own prndrvr.vbs
' first restart print spooler in order to release open files
'Set objWMIService = GetObject("winmgmts:" _
' & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Set colServiceList = objWMIService.ExecQuery _
' ("Select * from Win32_Service where Name='Spooler'")
'For each objService in colServiceList
' errReturn = objService.StopService()
'Next
'wscript.sleep 1000
'Set colServiceList = objWMIService.ExecQuery _
' ("Select * from Win32_Service where Name='Spooler'")
'For each objService in colServiceList
' errReturn = objService.StartService()
'Next
'oShell.Run "cscript %systemroot%\system32\prndrvr.vbs -x"
'********************************************************************************************************************
'Add new printers using either printui.dll or AddWindowsPrinterConnection
wscript.sleep 100
For Each strPrn in arrPrinters
strPrinter = (strNewSrv & strPrn)
'wscript.echo "installing " & strPrinter
strCmd = "rundll32 printui.dll,PrintUIEntry /in /n """ & strPrinter & """ /u /q /Gw"
objShell.Run strCmd,,true
' objNetwork.AddWindowsPrinterConnection strNewSrv & strPrn
Next
'********************************************************************************************************************
' Try to put back the default printer
'Set objFile = objFSO.OpenTextFile(userprrf & lockfile)
'Do Until objFile.AtEndOfStream
' strNewDefPrinter = objFile.ReadLine
'Loop
'objFile.Close
strNewDefault = (Replace(strdefPrinter,strOldSrv, strNewSrv))
'wscript.Echo "New default printer: " & strNewDefault
strCmd = "rundll32 printui.dll,PrintUIEntry /y /n """ & strrNewDefault & """ /u /q /Gw"
objShell.Run strCmd,,true
'objNetwork.SetDefaultPrinter strNewDefault
'********************************************************************************************************************
' Tell the user to check his default printer
beep = chr(007)
objShell.Run "cmd /c @echo " & beep & beep, 0
'with createobject("wscript.shell")
' .popup "Tous vos imprimantes réseau ont été installés. SVP vérifier et changer votre imprimante DÉFAULT si nécessaire.",30, "Printers Manager"
'end with
'objShell.Exec("control printers")
'********************************************************************************************************************
' We're done, let's leave a hidden file in userprofile, so at next login this script will exit
Set objFile = objFSO.CreateTextFile(userprrf & lockfile, true)
Set objFile = objFSO.GetFile(userprrf & lockfile)
objFile.Attributes = 2
Wscript.Quit
Thursday, May 01, 2014
Delete old printers and change the default
'Change default Printer and delete the old ones
'(c)2014 s@xxxxxxxx.com
' defaultlist example: service Client,\\2K12SRV\HP 4050 P005
'(c)2014 s@xxxxxxxx.com
' defaultlist example: service Client,\\2K12SRV\HP 4050 P005
PrintServer = "2K8SRV" 'Old Print server name goes here - case sensitive
listfile = "\defaultlist.txt"
lockfile = "\defaultprt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
Set objShell = CreateObject("WScript.Shell")
userprrf = objShell.Environment("PROCESS")("UserProfile")
strComputer = "."
'strCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(strComputer)
strCurPath = "\\2k12srv\netlogon\deploy" ' relpath doesn't seems to work on UNC
wscript.echo strCurPath
If (objFSO.FileExists(userprrf & lockfile)) Then
'Debug
'with createobject("wscript.shell")
'.popup userprrf & "Lockfile EXIST!" , 1 , "Info"
'end with
Wscript.Quit
End If
'On Error Resume Next
strName = objSysInfo.UserName
' Split full username by comma (warning: comma is a valid char in OU, verify personally that it doesn't exist in your OU!)
arrUserName = Split(strName, ",")
' remove OU= or DC= for the last 2 OU's
arrOU = Split(arrUserName(1), "=")
arrOU2 = Split(arrUserName(2), "=")
'put those OU toghether
strOU = arrOU2(1) & " " & arrOU(1)
' open the list of OU vs printers pairs
Set objFile = objFSO.OpenTextFile(strCurPath + listfile, 1)
Do Until objFile.AtEndOfStream
' they are separated by comma, first is OU second is printer
defaultArray = split(objFile.ReadLine,",")
readOU=defaultArray(0)
defaultprt=defaultArray(1)
' Debug
'with createobject("wscript.shell")
'.popup "Check: """ & strOU & """ = """ & readOU & """ Choose """ & defaultprt & """. " , 1 , "Info"
'end with
If strOU = readOU Then
' Debug
'with createobject("wscript.shell")
'.popup "Found: """ & strOU & """ = """ & readOU & """ Printer: """ & defaultprt & """. " , 5 , "Info"
'end with
' first ensure that the printer is installed, then set it default
objNetwork.AddWindowsPrinterConnection defaultprt
objNetwork.SetDefaultPrinter defaultprt
exit do
End If
Loop
objFile.Close
'Remove old printers
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
'Debug
'with createobject("wscript.shell")
'.popup "Name: " & objPrinter.Name , 1 , "Info"
'end with
'Wscript.Echo "Name: " & objPrinter.Name
i = 0
ReDim Preserve arrPrinterName(i)
arrPrinterName(i) = objPrinter.Name
If InStr(arrPrinterName(i), PrintServer) Then
Set objNetwork = WScript.CreateObject("WScript.Network")
'Debug
'with createobject("wscript.shell")
'.popup "Removing: " & arrPrinterName(i) , 5 , "Info"
'end with
objNetwork.RemovePrinterConnection arrPrinterName(i)
i=i+1
Else
'Debug
'with createobject("wscript.shell")
'.popup "Skipped: " & arrPrinterName(i) , 5 , "Info"
'end with
End If
Next
' Leave a lockfile in user's home
Set objFile1 = objFSO.CreateTextFile(userprrf & lockfile)
Wscript.Quit
Thursday, April 03, 2014
Modify ANZIOLITE.DEF
@echo off
echo (c) 2014 sorin@xxxxxxxx.com
setlocal enableextensions enabledelayedexpansion
set anzio15=Anzio15
set anzio16=Anzio16
set anzio17=Anzio17
set tgtfile=ANZIOWIN.DEF
for %%x in ( !anzio15! !anzio16! !anzio17! ) do (
for %%A IN ( "!programfiles!" "!programfiles(x86)!" ) do (
set mypath=%%~A\%%x\%tgtfile%
::echo mypath is: !mypath!
if exist "!mypath!" (
::echo anziowin found in !mypath!
%0\..\ssed.exe -e "s/allow-quit=1/allow-quit=0/g" -e "s/prompt-to-save=0/prompt-to-save=2/g" "!mypath!" > "!mypath!.new"
move /Y "!mypath!" "!mypath!.old"
move /Y "!mypath!.new" "!mypath!"
attrib +R "!mypath!"
)
)
)
if exist %appdata%\Anzio Lite\%tgtfile% (
::echo anziowin found in appdata
%0\..\ssed.exe -e "s/allow-quit=1/allow-quit=0/g" -e "s/prompt-to-save=0/prompt-to-save=2/g" "%appdata%\Anzio Lite\%tgtfile%" > "%appdata%\Anzio Lite\%tgtfile%.new"
move /Y "%appdata%\Anzio Lite\%tgtfile%" "%appdata%\Anzio Lite\%tgtfile%.old"
move /Y "%appdata%\Anzio Lite\%tgtfile%.new" "%appdata%\Anzio Lite\%tgtfile%"
attrib +R "%appdata%\Anzio Lite\%tgtfile%"
)
::End
endlocal
echo (c) 2014 sorin@xxxxxxxx.com
setlocal enableextensions enabledelayedexpansion
set anzio15=Anzio15
set anzio16=Anzio16
set anzio17=Anzio17
set tgtfile=ANZIOWIN.DEF
for %%x in ( !anzio15! !anzio16! !anzio17! ) do (
for %%A IN ( "!programfiles!" "!programfiles(x86)!" ) do (
set mypath=%%~A\%%x\%tgtfile%
::echo mypath is: !mypath!
if exist "!mypath!" (
::echo anziowin found in !mypath!
%0\..\ssed.exe -e "s/allow-quit=1/allow-quit=0/g" -e "s/prompt-to-save=0/prompt-to-save=2/g" "!mypath!" > "!mypath!.new"
move /Y "!mypath!" "!mypath!.old"
move /Y "!mypath!.new" "!mypath!"
attrib +R "!mypath!"
)
)
)
if exist %appdata%\Anzio Lite\%tgtfile% (
::echo anziowin found in appdata
%0\..\ssed.exe -e "s/allow-quit=1/allow-quit=0/g" -e "s/prompt-to-save=0/prompt-to-save=2/g" "%appdata%\Anzio Lite\%tgtfile%" > "%appdata%\Anzio Lite\%tgtfile%.new"
move /Y "%appdata%\Anzio Lite\%tgtfile%" "%appdata%\Anzio Lite\%tgtfile%.old"
move /Y "%appdata%\Anzio Lite\%tgtfile%.new" "%appdata%\Anzio Lite\%tgtfile%"
attrib +R "%appdata%\Anzio Lite\%tgtfile%"
)
::End
endlocal
Sunday, March 09, 2014
Setup Outlook profile and hack the location of Documents
'Setup Outlook profile and hack the location of My Documents without GPO
'(c)2010 neXt
Set WshShell = CreateObject("WScript.Shell")
On error Resume Next
set env = WshShell.Environment("PROCESS")
Set WshNet = CreateObject("WScript.Network")
homedrv = wshshell.regread("HKEY_CURRENT_USER\Volatile Environment\HOMEDRIVE")
homedir = wshshell.regread("HKEY_CURRENT_USER\Volatile Environment\HOMEPATH")
strUsername = WshNet.Username
if (IsEmpty(homedrv) Or IsEmpty(homedir)) then
dim WshNet, WMIService, Account
Set WshNet = WScript.CreateObject("WScript.Network")
Set WMIService = GetObject("winmgmts:\\.\root\cimv2")
Set Account = WMIService.Get("Win32_UserAccount.Name='" & WshNet.UserName & "',Domain='" & WshNet.UserDomain & "'")
userprofile = WshShell.ExpandEnvironmentStrings(WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" + Account.SID
+ "\ProfileImagePath"))
else
userprofile = homedrv & homedir
end if
set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("c:\Users\" & strUsername & "\Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Users\" & strUsername & "\Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Users\" & strUsername & "\My Documents", userprofile & "\Documents", TRUE
objFSO.DeleteFolder "c:\Users\" & strUsername & "\Documents"
End If
If objFSO.FolderExists("c:\Utilisateurs\" & strUsername & "\Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Users\" & strUsername & "\Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Utilisateurs\" & strUsername & "\My Documents", userprofile & "\Documents", TRUE
objFSO.DeleteFolder "c:\Utilisateurs\" & strUsername & "\Documents"
End If
If objFSO.FolderExists("c:\Documents and Users\" & strUsername & "\My Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Documents and Users\" & strUsername & "\My Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Documents and Users\" & strUsername & "\My Documents", userprofile, TRUE
objFSO.DeleteFolder "c:\Documents and Users\" & strUsername & "\My Documents"
End If
If objFSO.FolderExists("c:\Documents and Users\" & strUsername & "\Mes Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Documents and Users\" & strUsername & "\Mes Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Documents and Users\" & strUsername & "\Mes Documents", userprofile, TRUE
objFSO.DeleteFolder "c:\Documents and Users\" & strUsername & "\Mes Documents"
End If
WSHShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\FirstRunDialog","False"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\ImportPRF","\\server\netlogon\outlook.prf"
WSHShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\First-Run"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\FirstRunDialog","False"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\ImportPRF","\\server\netlogon\outlook.prf"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Video","\\server\home\%USERNAME%\Documents\Videos","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures","\\server\home\%USERNAME%\Documents\Pictures","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music","\\server\home\%USERNAME%\Documents\Music","REG_SZ"
'WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal","%HOMEDRIVE%\%HOMEPATH%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E}","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video","\\server\home\%USERNAME%\Documents\Videos","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures","\\server\home\%USERNAME%\Documents\Pictures","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music","\\server\home\%USERNAME%\Documents\Music","REG_EXPAND_SZ"
'WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E}","%HOMEDRIVE%\%HOMEPATH%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E}","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
'(c)2010 neXt
Set WshShell = CreateObject("WScript.Shell")
On error Resume Next
set env = WshShell.Environment("PROCESS")
Set WshNet = CreateObject("WScript.Network")
homedrv = wshshell.regread("HKEY_CURRENT_USER\Volatile Environment\HOMEDRIVE")
homedir = wshshell.regread("HKEY_CURRENT_USER\Volatile Environment\HOMEPATH")
strUsername = WshNet.Username
if (IsEmpty(homedrv) Or IsEmpty(homedir)) then
dim WshNet, WMIService, Account
Set WshNet = WScript.CreateObject("WScript.Network")
Set WMIService = GetObject("winmgmts:\\.\root\cimv2")
Set Account = WMIService.Get("Win32_UserAccount.Name='" & WshNet.UserName & "',Domain='" & WshNet.UserDomain & "'")
userprofile = WshShell.ExpandEnvironmentStrings(WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\" + Account.SID
+ "\ProfileImagePath"))
else
userprofile = homedrv & homedir
end if
set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("c:\Users\" & strUsername & "\Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Users\" & strUsername & "\Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Users\" & strUsername & "\My Documents", userprofile & "\Documents", TRUE
objFSO.DeleteFolder "c:\Users\" & strUsername & "\Documents"
End If
If objFSO.FolderExists("c:\Utilisateurs\" & strUsername & "\Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Users\" & strUsername & "\Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Utilisateurs\" & strUsername & "\My Documents", userprofile & "\Documents", TRUE
objFSO.DeleteFolder "c:\Utilisateurs\" & strUsername & "\Documents"
End If
If objFSO.FolderExists("c:\Documents and Users\" & strUsername & "\My Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Documents and Users\" & strUsername & "\My Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Documents and Users\" & strUsername & "\My Documents", userprofile, TRUE
objFSO.DeleteFolder "c:\Documents and Users\" & strUsername & "\My Documents"
End If
If objFSO.FolderExists("c:\Documents and Users\" & strUsername & "\Mes Documents") Then
'with createobject("wscript.shell")
'.popup "Moving c:\Documents and Users\" & strUsername & "\Mes Documents To " & userprofile, 1, "Info"
'end with
objFSO.CopyFolder "c:\Documents and Users\" & strUsername & "\Mes Documents", userprofile, TRUE
objFSO.DeleteFolder "c:\Documents and Users\" & strUsername & "\Mes Documents"
End If
WSHShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\First-Run"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\FirstRunDialog","False"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Setup\ImportPRF","\\server\netlogon\outlook.prf"
WSHShell.RegDelete "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\First-Run"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\FirstRunDialog","False"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Setup\ImportPRF","\\server\netlogon\outlook.prf"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Video","\\server\home\%USERNAME%\Documents\Videos","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures","\\server\home\%USERNAME%\Documents\Pictures","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Music","\\server\home\%USERNAME%\Documents\Music","REG_SZ"
'WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal","%HOMEDRIVE%\%HOMEPATH%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E}","\\server\home\%USERNAME%\Documents","REG_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Video","\\server\home\%USERNAME%\Documents\Videos","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures","\\server\home\%USERNAME%\Documents\Pictures","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Music","\\server\home\%USERNAME%\Documents\Music","REG_EXPAND_SZ"
'WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E}","%HOMEDRIVE%\%HOMEPATH%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\{374DE290-123F-4565-9164-39C4925E}","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal","\\server\home\%USERNAME%\Documents","REG_EXPAND_SZ"
Tuesday, February 04, 2014
Recover / from a full backup
If we have a nightly dd of the / partition and we need to put that on a new disk, we have to follow this procedure:
let's mount the image in /tmp/1 and the new disk in /media/sdb1:
fdisk -l media/server/disk2/backup/backup,img - note the start block and the sector size, then multiply them to obtain the mount offset.
Disk /media/server/disk2/backup/backup.img: 7.5 GiB, 8004304896 bytes, 15633408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0000d331
Device Boot Start End Blocks Id System
/media/server/disk2/backup/backup.img 1 * 62 15633407 7816673 83 Linux
512*62=31744
mount -t ext4 -o loop,ro,noexec,noload,offset=31744 /media/server/disk2/backup/backup.img /tmp/1
mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 -l root /dev/sdb1
tune2fs -o journal_data_writeback /dev/sdb1
mount /dev/sdb1/ /media/sdb1
then we can copy the content of that image to the new disk:
cd /tmp/1 && find . -depth -print | cpio -padmV /media/sdb1
we need to sed the new UUID (blkid /dev/sdb1) into /media/sdb1/boot/grub/menu.lst and /media/sdb1/etc/fstab, then
mount --bind /dev /media/sdb1/dev
mount --bind /proc /media/sdb1/proc
mount --bind /sys /media/sdb1/sys
followed by chroot /media/sdb1 /bin/bash
in the chroot we need to check the value of the actual kernel in /lib/modules/xxxxxx.xx and run a mv /boot/initrd-xxxxxxx.xx.img /boot/old.img then
dracut /boot/initrd-xxxxxxx.xx.img xxxxxx.xx
As an alternative we can change the UUID of the new disk with tune2fs -U `old_uuid` /dev/device-name
Now we can run an /boot/grub/install-grub (or run grub, followed by find /boot/grub/stage1 then root (hd1,0) and setup (hd1) ) and finally put the new disk in the machine and boot!
let's mount the image in /tmp/1 and the new disk in /media/sdb1:
fdisk -l media/server/disk2/backup/backup,img - note the start block and the sector size, then multiply them to obtain the mount offset.
Disk /media/server/disk2/backup/backup.img: 7.5 GiB, 8004304896 bytes, 15633408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0000d331
Device Boot Start End Blocks Id System
/media/server/disk2/backup/backup.img 1 * 62 15633407 7816673 83 Linux
512*62=31744
mount -t ext4 -o loop,ro,noexec,noload,offset=31744 /media/server/disk2/backup/backup.img /tmp/1
mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 -l root /dev/sdb1
tune2fs -o journal_data_writeback /dev/sdb1
mount /dev/sdb1/ /media/sdb1
cd /tmp/1 && find . -depth -print | cpio -padmV /media/sdb1
we need to sed the new UUID (blkid /dev/sdb1) into /media/sdb1/boot/grub/menu.lst and /media/sdb1/etc/fstab, then
mount --bind /dev /media/sdb1/dev
mount --bind /proc /media/sdb1/proc
mount --bind /sys /media/sdb1/sys
followed by chroot /media/sdb1 /bin/bash
in the chroot we need to check the value of the actual kernel in /lib/modules/xxxxxx.xx and run a mv /boot/initrd-xxxxxxx.xx.img /boot/old.img then
dracut /boot/initrd-xxxxxxx.xx.img xxxxxx.xx
As an alternative we can change the UUID of the new disk with tune2fs -U `old_uuid` /dev/device-name
Now we can run an /boot/grub/install-grub (or run grub, followed by find /boot/grub/stage1 then root (hd1,0) and setup (hd1) ) and finally put the new disk in the machine and boot!
Friday, January 10, 2014
This one is touchy and not very fairplay ;)
It is looking at your MAC address and based on that, it creates some binary ids in global.conf. Change your MACs, remove the confs and you should be able to help your friends without the pesky time limit :)
#!/bin/bash
hw1=`echo -n 00; dd bs=1 count=5 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
sudo /sbin/ifconfig eth0 | grep HW
sudo /sbin/ifconfig eth0 hw ether $hw1
sudo /sbin/ifconfig eth0 | grep HW
hw2=`echo -n 00; dd bs=1 count=5 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
sudo /sbin/ifconfig wlan0 down
sudo /sbin/ifconfig wlan0 hw ether $hw2
sudo rm -rf ~/.teamxxxxxx*
sudo rm -rf ~/.config/teamxxxxxx*
sudo rm -rf /root/.teamxxxxxx*
sudo rm -rf /root/.config/teamxxxxxx*
sudo rm -rf /opt/teamxxxxxx9/config/*
sudo killall -9 teamxxxxxxd
if [ ! "$(pidof teamxxxxxxd)" ]; then
sudo /opt/tteamxxxxxx9/tv_bin/teamxxxxxxd -d
x=5
while [ $x -ge 0 ]; do
echo -en "Wait $x seconds..."\\r
x=$(( $x - 1 ))
sleep 1
done
fi
sudo /opt/teamxxxxxx9/tv_bin/script/teamxxxxxx && sudo killall -9 teamxxxxxxd
For the not-officially-supported .tar.gz, just go and modify the launcher itself in the extracted folder:
#!/bin/bash
# If you can read this text, you probably attempted to start TeamXxxxxx.
# Please open a terminal (Konsole, gnome-terminal, xterm)
# Navigate to this folder (type 'cd /path/to/teamxxxxxx' [Enter])
# then execute TeamXxxxxx (type './teamxxxxxx' [Enter])
hw0=`echo -n 00; dd bs=1 count=5 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
while read interface; do
sudo ip link set dev $interface address $hw0
done < <(sudo ifconfig | cut -d" " -f1 | sed '/^$/d' | grep -v lo)
sudo /usr/bin/systemctl restart NetworkManager.service
x=4
while [ $x -ge 0 ]; do
echo -en "Wait $x seconds for the network to be up..."\\r
x=$(( $x - 1 ))
sleep 1
done
TV_SCRIPT_DIR="$(dirname "$(readlink -e "$0")")"
rm -rf $TV_SCRIPT_DIR/../../profile
rm -rf $TV_SCRIPT_DIR/../../config/*
source "$TV_SCRIPT_DIR/tvw_main"
Main "$@"
#!/bin/bash
hw1=`echo -n 00; dd bs=1 count=5 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
sudo /sbin/ifconfig eth0 | grep HW
sudo /sbin/ifconfig eth0 hw ether $hw1
sudo /sbin/ifconfig eth0 | grep HW
hw2=`echo -n 00; dd bs=1 count=5 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
sudo /sbin/ifconfig wlan0 down
sudo /sbin/ifconfig wlan0 hw ether $hw2
sudo rm -rf ~/.teamxxxxxx*
sudo rm -rf ~/.config/teamxxxxxx*
sudo rm -rf /root/.teamxxxxxx*
sudo rm -rf /root/.config/teamxxxxxx*
sudo rm -rf /opt/teamxxxxxx9/config/*
sudo killall -9 teamxxxxxxd
if [ ! "$(pidof teamxxxxxxd)" ]; then
sudo /opt/tteamxxxxxx9/tv_bin/teamxxxxxxd -d
x=5
while [ $x -ge 0 ]; do
echo -en "Wait $x seconds..."\\r
x=$(( $x - 1 ))
sleep 1
done
fi
sudo /opt/teamxxxxxx9/tv_bin/script/teamxxxxxx && sudo killall -9 teamxxxxxxd
For the not-officially-supported .tar.gz, just go and modify the launcher itself in the extracted folder:
#!/bin/bash
# If you can read this text, you probably attempted to start TeamXxxxxx.
# Please open a terminal (Konsole, gnome-terminal, xterm)
# Navigate to this folder (type 'cd /path/to/teamxxxxxx' [Enter])
# then execute TeamXxxxxx (type './teamxxxxxx' [Enter])
hw0=`echo -n 00; dd bs=1 count=5 if=/dev/random 2>/dev/null |hexdump -v -e '/1 ":%02X"'`
while read interface; do
sudo ip link set dev $interface address $hw0
done < <(sudo ifconfig | cut -d" " -f1 | sed '/^$/d' | grep -v lo)
sudo /usr/bin/systemctl restart NetworkManager.service
x=4
while [ $x -ge 0 ]; do
echo -en "Wait $x seconds for the network to be up..."\\r
x=$(( $x - 1 ))
sleep 1
done
TV_SCRIPT_DIR="$(dirname "$(readlink -e "$0")")"
rm -rf $TV_SCRIPT_DIR/../../profile
rm -rf $TV_SCRIPT_DIR/../../config/*
source "$TV_SCRIPT_DIR/tvw_main"
Main "$@"
Wednesday, January 01, 2014
Recursively change owner/permisions
$1 is the source of the rights/ownership, $2 is the target
#!/bin/sh
chmod --reference $1 $2
chown
--reference $1 $2
if [ -d $1 ]
then
if [ "x`ls $1`" != "x" ]
then
for f in `ls $1`
do
$0 $1/$f $2/$f
done
fi
fi
Subscribe to:
Posts (Atom)