Tuesday, 16 November 2010

How to remotely list scheduled tasks

I had the need of getting all details of the scheduled tasks of our servers, I could use a lot of other complex ways, but I still prefer simplicity of batch:
1. Create a file with the hostnames of all the computers you need to check for the
scheduled tasks (tasks.txt):

2. Create a batch file with (tasks.bat):
del out.csv
echo "HostName","TaskName","Next Run Time","Status","Logon Mode","Last Run Time","Last Result","Author","Task To Run","Start In","Comment","Scheduled Task State","Idle Time","Power Management","Run As User","Delete Task If Not Rescheduled","Stop Task If Runs X Hours and X Mins","Schedule","Schedule Type","Start Time","Start Date","End Date","Days","Months","Repeat: Every","Repeat: Until: Time","Repeat: Until: Duration","Repeat: Stop If Still Running">> out.csv
FOR /F %%a in (tasks.txt) Do schtasks.exe /query /fo csv /s %%a /v | FIND "%%a" >> out.csv

3. Run the batch file with a user that have admin rights on the server, you will get a CSV that can be easily imported on Excel or a similar application.

Saturday, 13 November 2010

Ultimate boot CD for Windows in USB

Ultimate Boot CD for Windows is an indispensable tool when a system needs to be recovered. But when you have for instance a vĂ­rus on a computer, it's not easy to keep it up to date, because it runs on a CD that can only be updated when you write it. So it's much more flexible to have this tool on an USB pen, where I can write and update some files. There are some nice tools to make an ISO available on USB boot, I highly recommend these:
- WinSetupFromUSB - great but on Windows 7 x64 does not work well with UAC active, also supports install Windows from USB
- USB boot without BIOS support - this works great for me and can make a system boot even without USB boot support, by using an ISO that boots with USB support.

Additionally to this, I use Ketarin, a must have tool to keep virus definitions updated on the USB.

Thursday, 14 October 2010

Dealing with mixed architectures on Windows

I'm deploying Windows 7 while keeping Windows XP machines at the same time. We have to create some registry entries for both x86 and x64 so the way I to do it is to create a bath file that runs like this:

@echo off
 set arch=%windir%\system32
) ELSE (
 set arch=%windir%\syswow64

REM Put here your X86 stuff
GOTO Final

REM Put here your X64 stuff
GOTO Final

%arch%\REG QUERY "HKLM\SOFTWARE\software name"
IF %Errorlevel% == 1 GOTO ADDREG

%arch%\REG ADD "HKLM\SOFTWARE\software name" /v "key" /t REG_SZ /d "text" /f

Wednesday, 13 October 2010

Shrink of SQL log files

Microsoft SQL 2008 can sometimes be tricky to shrink the log files in a maintenance plan. This will force the shrink of the log files:

sp_MSForEachDb 'IF ''?'' NOT IN (''master'', ''tempdb'', ''tempdev'', ''model'', ''msdb'')
AND (SELECT recovery_model FROM master.sys.databases WHERE name = '
'?'') = 1
AND (SELECT is_read_only FROM master.sys.databases WHERE name = '
'?'') = 0
declare @LogFile nvarchar(2000)
USE [?]
SELECT @LogFile = sys.database_files.name
FROM sys.database_files
WHERE (sys.database_files.type = 1)
PRINT @LogFile

Sunday, 10 October 2010

GazoPa - advanced image search

In the previous post I've mentioned TinyEye, but while exploring the web I've come across GazoPa.com, an even more advanced image search engine where we can search for similar images, or even sketch a draw of what we are searching for. Very cool!

Friday, 3 September 2010

Content aware image search

Today I was searching the net and I found a neat content aware search engine, www.tineye.com
This can be very useful when you want to check who is using an image that you've own. In a small search I could find some sites using my panoramio pictures, without asking me anything. So they are doing business using copyrighted images.

I come across many other uses, for instance  you need a better resolution image from a small icon you need, tineye will for sure help you on this!
input image:
output from tineye:

Share your uses on comments please! Have fun.

Wednesday, 11 August 2010

I suspect I have a virus, what should I do first?

Viruses are very common, if you suspect of a file, the first thing you should do is to send it to Virustotal and have a report of multiple antivirus scans. This can be done either by uploading it to www.virustotal.com or by sending it by email to scan@virustotal.com with the word SCAN in the subject field. According to the scan results you should report that file to your antivirus producer so he can integrate that virus in their definitions.

Check services running under user accounts

How to check if service is running under a different user account on all computers?

Using Lansweeper, I only had to make this report:
SELECT     TOP (1000000) tblcomputers.Computername, tblcomputers.ComputerUnique, tblcomputers.Domain, tblServices.Caption AS ServiceDescription, 
tblServices.Lastchanged, tblServices.Startname
tblcomputers ON tblServices.Computername = tblcomputers.Computername INNER JOIN
tblComputersystem ON tblcomputers.Computername = tblComputersystem.Computername
WHERE (tblServices.Startname <> 'LocalSystem') AND (tblServices.Startname <> 'NT AUTHORITY\LocalService') AND
(tblServices.Startname <> 'NT AUTHORITY\NetworkService')
ORDER BY tblcomputers.Computer

Tuesday, 10 August 2010

Nircmd - when you need batch stuff on remote computers

Nircmd is quite an handy utility, it saves me a lot of work when I need something changed on my site computers.
A sample that shows the flexibility of this great and freeware tool:
- Detect and repair of MS Office is not working since I had a change of the server where Microsoft Office sources where used to install Office, or I want to add a new path (the installer can work with multiple source definitions):
nircmd elevatecmd remote \\hostname_of_computer regsetval sz "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9040110900063D11C8EF10054038389C\SourceList\Net" "2" "\\new_server\O2003pro3\source"


elevatecmd - used to ensure you run the command with administrator rights
remote - run the command remotelly on \\hostname_of_computer
regsetval - set the registry value
sz - the value type is string
"HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9040110900063D11C8EF10054038389C\SourceList\Net" - key in registry

    "2" - value name in registry
    "\\new_server\O2003pro3\source" - value data in registry

    If you need to apply that same fix on multiple remote computers, you can do it like this:
    nircmd elevatecmd multiremote "c:\hostnames.txt" sz "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\9040110900063D11C8EF10054038389C\SourceList\Net" "2" "\\new_server\O2003pro3\source"

    The file c:\hostnames.txt must contain host names of the computers where you want this "fix" to be installed (line by line).

    (more to come)