Login   Search
Skip Navigation Links
Home
Application Security Tips
Oracle , PL/SQL
IT Product Reviews
Project Management
Forum
Contact Us
Links & References
Avoid SQL Injection attack
Threats and Countermeasures: S.T.R.I.D.E
Input Validation
Session Management
Authentication Mechanism
Cross Site Scripting Vulnerabilities
Configuration Management
Scroll up
Scroll down
Oracle 9i - Programming basics PL/SQL
PL/SQL - Conditional Statements – IF
PL/SQL -Nested Block
LOOPS in PL/SQL
PL/SQL Records
Cursors in PL/SQL
PL/SQL Tables
PL/SQL Exceptions
PL/SQL Procedures
PL/SQL Functions
Oracle supplied packages
Packages
PL/SQL Ref Cursors
Types in Oracle PL/SQL
Varrays
Nested Table
Bfile and LOBs
Bulk Binding
Know Depandencies
PL/SQL Wrapper
Triggers
Scroll up
Scroll down
DBMS_SQL package
DBMS_DDL Package
DBMS_JOB Package
UTL_FILE Package
DBMS_METADATA Package
DBMS_PIPE Package
DBMS_SESSION Package
Scroll up
Scroll down

 

Blog

  • Imperativeness of agile methodology in software development
  • Get list of installed softwares on machines in your network
  • VMWare - Error - the vmware authorization service is not running
  • Add chart / graphs in ASP.net application / website
  • Microsoft Ramp Up

Blog

  • Review: uCertify.com: PrepKit for: 70-529 (C#)
  • Bird eye Review: uCertify.com: PrepKit for: 70-529 (C#)
Skip Navigation Links

> Blog entries about: Tips & Tricks
Get list of installed softwares on machines in your network

I was looking for a way to get list of softwares installed in machines in our network for verifying something. I did not wanted to go & login in each machine & then collection list of softwares from add / remove programs. 

So I decided to write a small program that will do this for me.

This is how we can do it. List that you see in add remove program is stored in Machine registry at path SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall  under local machine.

So your program will connect to registry of each machine specified & read the list. Then compile that list by removing list items such as Updates / Fixes etc as per requirement.

Below function will enumerate the softwares installed in a text file & also will display it on console application.

private static void WriteSoftwareListToFile(string MachineName , string ReportFileName)

{

StreamWriter sw;

if (File.Exists(ReportFileName))

{

sw = File.AppendText(ReportFileName);

}

else

{

sw = File.CreateText(ReportFileName);

}

sw.WriteLine("\r\nSoftwares installed on " + MachineName +

" on " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString());

//Registry path which has information of all the softwares installed on machine

string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";

// using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(uninstallKey))

sw.WriteLine("\r\nSoftware Name \t Software Version");

try

{

using (RegistryKey rk =

RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, MachineName).

OpenSubKey(uninstallKey))

{

foreach (string skName in rk.GetSubKeyNames())

{

using (RegistryKey sk = rk.OpenSubKey(skName))

{

string SoftwareName = string.Empty;

string SoftwareVersion = string.Empty;

try

{

SoftwareName = sk.GetValue("DisplayName").ToString();

SoftwareVersion = sk.GetValue("DisplayVersion").ToString();

}

catch (NullReferenceException exNull)

{

SoftwareName = string.Empty;

SoftwareVersion = string.Empty;

}

if (SoftwareName != string.Empty)

{

//Exclude Updates , Fixes

if (!(SoftwareName.Contains("Security Update for Windows") ||

SoftwareName.Contains("Hotfix for") ||

SoftwareName.Contains("Update for") ||

SoftwareName.Contains("Update for Windows")))

{

Console.WriteLine(SoftwareName + " " + SoftwareVersion);

sw.WriteLine(SoftwareName + "\t" + SoftwareVersion);

}

}

}

}

}

}

catch (Exception Ex)

{

sw.WriteLine("\r\n Exception :" + Ex.Message);

}

sw.Close();

}

 

You can call this functions for all require machines in your network like below. Please note if you are running the application your domain ID need to have registry read access for all the machines your are accessing.

 

static void Main(string[] args)

{

string[] Machines = new string[]

{

"MachineHostName1",

"MachineHostName2",

"MachineHostName3",

"MachineHostName4",

"MachineHostName5",

"MachineHostName6" };

string FILE_NAME = "SoftwareList_" + DateTime.Now.ToShortDateString().Replace("/", "") + ".log";

for (int i = 0; i < Machines.Length; i++ )

WriteSoftwareListToFile(Machines[i], FILE_NAME);

Console.ReadLine(); // To make the o/p readable.

}

{1/25/2010 12:28 PM} {0 comments}  {Tags: C#, Code Samples, Programming, Tips & Tricks}
VMWare - Error - the vmware authorization service is not running

I have windows vista home premium on my laptop. One day suddenly my VMWare started giving error "the vmware authorization service is not running " while starting virtual machine. I googled on internet & found KB Item on VMWare site    http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1007131

It said, go to compute management & give admin rights to VMWare user & then reinstall the VMWare . Looks easy.  I started following steps . But wait.. where is familiar screen of user management.  Windows Vista Home Premium do not have provision to use GUI user management consol. Thats not fair !!

Google one more time & here you go. http://social.technet.microsoft.com/Forums/en/itprovistasecurity/thread/e3d50d7f-deba-4a79-b347-72ed3d14d940 

Lot of good information is mention on this thread about user management using command line. Use below command to list users on computer & get exact name of VMWareUser

> NET USERS  

Syntax for adding for adding or removing user from group is

NET LOCALGROUP <<groupname>> <<user name>> {/ADD | /DELETE}

So below command should give admin right to VMWare user

>NET LOCALGROUP Administrators __vmware_user__ /add

But Ooops !! Got an error.

System error 5 has occurred.

Access is denied.

I am logged in as admin user still why would I get this error ?  Okey.. this is access error so my command line console is not having enough rights . Thanks to Windows Vista's User Account Control

Now right click on Command Prompt Menu & Run it as an Administrator. Now I was able to add VMWare user to administrators group from command line.  I have not yet reinstalled the VMware but I am still getting the same error. "the vmware authorization service is not running ". To to try something more , I right clicked VMWare Workstation & Ran it as administrator. I was able to start my workstation .

:) that was simple ..

 

 

 

{1/19/2010 7:04 PM} {0 comments}  {Tags: Tips & Tricks, Troubleshooting, Errors}
Use your IT skills to earn money

Online Jobs , Freelancing  , and lot more

 

The On Demand Global Workforce - oDesk
{9/29/2009 9:58 PM} {0 comments}  {Tags: Programming, Tips & Tricks}
Check free disk of your servers / computers on network

Since few days I was facing a problem that some of the servers were short of free space due to disk full.

I was looking for quick & simple way to monitor free space on server. I found some sripts on internet & modified it to suit my requirement .

Below script connects to all listed servers using WMI query , creates a report on c:\ . It can also email the report if you want.

How to use this script ?

  • Copy below code in notepad 
  • List names of computers / server in arrServers .
  • Set flag for email true / false & settings for email server
  • Save file as HDDSpaceCheck.vbs file. 
  • Double click vbs file . It shall show report in minute or so depending on number of servers.
  • You can use windows scheduled task to schedule this activity & get email notification .

 

' ******************** Start of Script *************

' Author : Rahul S Bagal  07/13/2009
' This Script Checks Free Disk space in servers defined in "arrServers "


' Define Names of servers to be checked for disk space
arrServers = Array("Server1","Server2","Server3","Server4")

' Email Settings

Const SendEmail = True    ' Turn this flag to false you you do not wish to receive the report in email
const DisplayReportOnScreen  =  True  ' Turn this flag if you do not want to open the created report file. 

strServer = "MailserverName"
intPort = 25
strFrom = "
DoNotReply@domain.com"   ' Set from Email address for email reports
strTo = "
YourName@domain.com"       ' Set to email address where you wish to receive email

' Report File defination
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

' This is the file name where email
strFilePath = "C:\HDDRerport" & Month ( now ) & Day(now) & year(now) & ".txt"


'The WMI query bit...
For i = LBound(arrServers) To UBound(arrServers)
 strBody = strBody & "Please find below a report on local disks for server : " & arrServers(i) & vbCrLf & vbCrLf
 On Error Resume Next
 Set objWMI = GetObject("winmgmts:\\" & arrServers(i) & "\root\cimv2")
 Set colDisks = objWMI.ExecQuery("Select * from Win32_LogicalDisk Where DriveType=3")' Where DeviceID = '" & strDiskLetter & "'")
 If Err.Number = 0 Then
  For Each objDisk in colDisks
   strBody = strBody & "Drive " & objDisk.DeviceID & " - " & vbTab & "Total Size(MB): " & bytesToMB(objDisk.Size) _
    & vbTab & vbTab & "Free Space(MB): " & bytesToMB(objDisk.FreeSpace) & vbtab & " Free Space ( % ) : " & round( bytesToMB(objDisk.FreeSpace) / bytesToMB(objDisk.Size) * 100 , 2 ) & vbcrlf
  Next
 Else
  strBody = strBody & "!ERROR! connecting to " & arrServers(i) & ". " & Err.Number & " - " & Err.Description
  Err.Clear
 End If
 strBody = strBody & vbCrLf & vbCrLf
Next

' Write to File

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    (strFilePath , ForWriting , True)
objTextFile.WriteLine("Server Disk Space Report" & vbCrLf )
objTextFile.WriteLine(strBody )
objTextFile.Close
set objFSO = nothing

'email Section

if SendEmail = True then 
 On Error Goto 0
 Set objMail = CreateObject("CDO.Message")
 With objMail
  .Subject = "Server Disk Space Report"
  .From = strFrom
  .To = strTo
  .TextBody = strBody
  .Configuration.Fields.Item("
http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 '2 = use a specified SMTP server, 1 = use local SMTP service
  .Configuration.Fields.Item("
http://schemas.microsoft.com/cdo/configuration/smtpserver") = strServer 'Your SMTP Server
  .Configuration.Fields.Item("
http://schemas.microsoft.com/cdo/configuration/smtpserverport") = intPort 'Server port
  .Configuration.Fields.Update
  .Send
 End With
end if

Set objMail = Nothing
Set objWMI = Nothing
Set colDisks = Nothing
Set objNet = Nothing


' Display report if flag is set

if DisplayReportOnScreen = True then
 Dim WshShell
 Set WshShell = WScript.CreateObject("WScript.Shell")
 WshShell.Run strFilePath
 Set WshShell = nothing
end if

Function bytesToMB(intbytes)
 bytesToMB = FormatNumber((intbytes / 1024) / 1024,,,,-1)
End Function

' ******************** End of Script *************

{7/13/2009 5:16 AM} {0 comments}  {Tags: Programming, WMI, VB Script, Tips & Tricks}



Designed & Developed by Rahul Bagal