I have a VB script that writes a list of installed applications to a text
file that is named the computername.

It works okay except that it does not list the user, so it is difficult and
time consuming to find which users are assigned to those computers.

Can someone help me and show what needs to be added (and where) for the
script to also write the name of at least the currently logged on user?
Ideally, it would also write the list of all the domain user profiles on
that computer (or the domain user profiles on that computer that have been
used in the last 30 days).


Here is the script that lacks that added functionality:




on error resume next

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("\\server\folder\folder\inv\" &
strcomputer & ".txt", True)

strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"

Set objReg = GetObject("winmgmts://" & strComputer & _
"/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys

For Each strSubkey In arrSubkeys
intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
strEntry1a, strValue1)
If intRet1 <> 0 Then
objReg.GetStringValue HKLM, strKey & strSubkey, _
strEntry1b, strValue1
End If
If strValue1 <> "" Then
objTextFile.WriteLine strValue1 & "¿ " & strcomputer & "¿"
End If
Next

strKey2 =
"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry2a = "DisplayName"
strEntry2b = "QuietDisplayName"

Set objReg = GetObject("winmgmts://" & strComputer & _
"/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey2, arrSubkeys

For Each strSubkey In arrSubkeys
intRet2 = objReg.GetStringValue(HKLM, strKey2 & strSubkey, _
strEntry2a, strValue2)
If intRet2 <> 0 Then
objReg.GetStringValue HKLM, strKey & strSubkey, _
strEntry2b, strValue2
End If
If strValue2 <> "" Then
objTextFile.WriteLine strValue2 & "¿ " & strcomputer & "¿"
End If
Next

objTextFile.Close

Re: Software Inventory script help by Patrick

Patrick
Tue Apr 11 02:00:14 CDT 2006

Take a look at my SYDI-Server script at http://sydi.sourceforge.net, you
might find it useful in other ways too. It has the information about the
last logged on user, but doesn't list which profiles are on the computer.

--
http://ogenstad.net


"Valkan" <spam#npspam.com> wrote in message
news:lq-dnR9lqcIRZqfZnZ2dnUVZ_umdnZ2d@comcast.com...
> I have a VB script that writes a list of installed applications to a text
> file that is named the computername.
>
> It works okay except that it does not list the user, so it is difficult
and
> time consuming to find which users are assigned to those computers.
>
> Can someone help me and show what needs to be added (and where) for the
> script to also write the name of at least the currently logged on user?
> Ideally, it would also write the list of all the domain user profiles on
> that computer (or the domain user profiles on that computer that have been
> used in the last 30 days).
>
>
> Here is the script that lacks that added functionality:
>
>
>
>
> on error resume next
>
> Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
> Set objNetwork = CreateObject("Wscript.Network")
> strComputer = objNetwork.ComputerName
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.CreateTextFile("\\server\folder\folder\inv\" &
> strcomputer & ".txt", True)
>
> strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
> strEntry1a = "DisplayName"
> strEntry1b = "QuietDisplayName"
>
> Set objReg = GetObject("winmgmts://" & strComputer & _
> "/root/default:StdRegProv")
> objReg.EnumKey HKLM, strKey, arrSubkeys
>
> For Each strSubkey In arrSubkeys
> intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
> strEntry1a, strValue1)
> If intRet1 <> 0 Then
> objReg.GetStringValue HKLM, strKey & strSubkey, _
> strEntry1b, strValue1
> End If
> If strValue1 <> "" Then
> objTextFile.WriteLine strValue1 & "¿ " & strcomputer & "¿"
> End If
> Next
>
> strKey2 =
> "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
> strEntry2a = "DisplayName"
> strEntry2b = "QuietDisplayName"
>
> Set objReg = GetObject("winmgmts://" & strComputer & _
> "/root/default:StdRegProv")
> objReg.EnumKey HKLM, strKey2, arrSubkeys
>
> For Each strSubkey In arrSubkeys
> intRet2 = objReg.GetStringValue(HKLM, strKey2 & strSubkey, _
> strEntry2a, strValue2)
> If intRet2 <> 0 Then
> objReg.GetStringValue HKLM, strKey & strSubkey, _
> strEntry2b, strValue2
> End If
> If strValue2 <> "" Then
> objTextFile.WriteLine strValue2 & "¿ " & strcomputer & "¿"
> End If
> Next
>
> objTextFile.Close
>
>



Re: Software Inventory script help by maximillianx

maximillianx
Tue Apr 11 09:55:01 CDT 2006

For currently logged on users, try:

(insert this somewhere after your strComputer declaration)

Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT UserName FROM
Win32_ComputerSystem")

For Each objItem In colItems
if objItem.username <> "" Then
WScript.Echo "Logged on User: " & objItem.UserName
Else
wscript.echo "There are no users currently logged into " &
strComputer
End if
Next



"Valkan" <spam#npspam.com> wrote in message
news:lq-dnR9lqcIRZqfZnZ2dnUVZ_umdnZ2d@comcast.com...
>I have a VB script that writes a list of installed applications to a text
>file that is named the computername.
>
> It works okay except that it does not list the user, so it is difficult
> and time consuming to find which users are assigned to those computers.
>
> Can someone help me and show what needs to be added (and where) for the
> script to also write the name of at least the currently logged on user?
> Ideally, it would also write the list of all the domain user profiles on
> that computer (or the domain user profiles on that computer that have been
> used in the last 30 days).
>
>
> Here is the script that lacks that added functionality:
>
>
>
>
> on error resume next
>
> Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
> Set objNetwork = CreateObject("Wscript.Network")
> strComputer = objNetwork.ComputerName
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.CreateTextFile("\\server\folder\folder\inv\" &
> strcomputer & ".txt", True)
>
> strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
> strEntry1a = "DisplayName"
> strEntry1b = "QuietDisplayName"
>
> Set objReg = GetObject("winmgmts://" & strComputer & _
> "/root/default:StdRegProv")
> objReg.EnumKey HKLM, strKey, arrSubkeys
>
> For Each strSubkey In arrSubkeys
> intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
> strEntry1a, strValue1)
> If intRet1 <> 0 Then
> objReg.GetStringValue HKLM, strKey & strSubkey, _
> strEntry1b, strValue1
> End If
> If strValue1 <> "" Then
> objTextFile.WriteLine strValue1 & "¿ " & strcomputer & "¿"
> End If
> Next
>
> strKey2 =
> "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
> strEntry2a = "DisplayName"
> strEntry2b = "QuietDisplayName"
>
> Set objReg = GetObject("winmgmts://" & strComputer & _
> "/root/default:StdRegProv")
> objReg.EnumKey HKLM, strKey2, arrSubkeys
>
> For Each strSubkey In arrSubkeys
> intRet2 = objReg.GetStringValue(HKLM, strKey2 & strSubkey, _
> strEntry2a, strValue2)
> If intRet2 <> 0 Then
> objReg.GetStringValue HKLM, strKey & strSubkey, _
> strEntry2b, strValue2
> End If
> If strValue2 <> "" Then
> objTextFile.WriteLine strValue2 & "¿ " & strcomputer & "¿"
> End If
> Next
>
> objTextFile.Close
>
>



Re: Software Inventory script help by FootBallUBet

FootBallUBet
Tue Apr 11 11:00:03 CDT 2006

on error resume next
' Get Current Users Information
set shell =3D WScript.CreateObject( "WScript.Shell" )
username =3D shell.ExpandEnvironmentStrings("%USERNAME%")
msgbox username
server =3D shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
msgbox server

Patrick Ogenstad wrote:
> Take a look at my SYDI-Server script at http://sydi.sourceforge.net, you
> might find it useful in other ways too. It has the information about the
> last logged on user, but doesn't list which profiles are on the computer.
>
> --
> http://ogenstad.net
>
>
> "Valkan" <spam#npspam.com> wrote in message
> news:lq-dnR9lqcIRZqfZnZ2dnUVZ_umdnZ2d@comcast.com...
> > I have a VB script that writes a list of installed applications to a te=
xt
> > file that is named the computername.
> >
> > It works okay except that it does not list the user, so it is difficult
> and
> > time consuming to find which users are assigned to those computers.
> >
> > Can someone help me and show what needs to be added (and where) for the
> > script to also write the name of at least the currently logged on user?
> > Ideally, it would also write the list of all the domain user profiles =
on
> > that computer (or the domain user profiles on that computer that have b=
een
> > used in the last 30 days).
> >
> >
> > Here is the script that lacks that added functionality:
> >
> >
> >
> >
> > on error resume next
> >
> > Const HKLM =3D &H80000002 'HKEY_LOCAL_MACHINE
> > Set objNetwork =3D CreateObject("Wscript.Network")
> > strComputer =3D objNetwork.ComputerName
> >
> > Set objFSO =3D CreateObject("Scripting.FileSystemObject")
> > Set objTextFile =3D objFSO.CreateTextFile("\\server\folder\folder\inv\"=
&
> > strcomputer & ".txt", True)
> >
> > strKey =3D "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
> > strEntry1a =3D "DisplayName"
> > strEntry1b =3D "QuietDisplayName"
> >
> > Set objReg =3D GetObject("winmgmts://" & strComputer & _
> > "/root/default:StdRegProv")
> > objReg.EnumKey HKLM, strKey, arrSubkeys
> >
> > For Each strSubkey In arrSubkeys
> > intRet1 =3D objReg.GetStringValue(HKLM, strKey & strSubkey, _
> > strEntry1a, strValue1)
> > If intRet1 <> 0 Then
> > objReg.GetStringValue HKLM, strKey & strSubkey, _
> > strEntry1b, strValue1
> > End If
> > If strValue1 <> "" Then
> > objTextFile.WriteLine strValue1 & "=BF " & strcomputer & "=BF"
> > End If
> > Next
> >
> > strKey2 =3D
> > "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
> > strEntry2a =3D "DisplayName"
> > strEntry2b =3D "QuietDisplayName"
> >
> > Set objReg =3D GetObject("winmgmts://" & strComputer & _
> > "/root/default:StdRegProv")
> > objReg.EnumKey HKLM, strKey2, arrSubkeys
> >
> > For Each strSubkey In arrSubkeys
> > intRet2 =3D objReg.GetStringValue(HKLM, strKey2 & strSubkey, _
> > strEntry2a, strValue2)
> > If intRet2 <> 0 Then
> > objReg.GetStringValue HKLM, strKey & strSubkey, _
> > strEntry2b, strValue2
> > End If
> > If strValue2 <> "" Then
> > objTextFile.WriteLine strValue2 & "=BF " & strcomputer & "=BF"
> > End If
> > Next
> >
> > objTextFile.Close
> >
> >


Re: Software Inventory script help by Tcs

Tcs
Wed Apr 12 08:33:30 CDT 2006

I've only tried the server script so far... This is *awesome*! EXCELLENT!

On Tue, 11 Apr 2006 09:00:14 +0200, "Patrick Ogenstad" <patrick dot ogenstad at
netsafe dot se> wrote:

>Take a look at my SYDI-Server script at http://sydi.sourceforge.net, you
>might find it useful in other ways too. It has the information about the
>last logged on user, but doesn't list which profiles are on the computer.

Re: Software Inventory script help by Valkan

Valkan
Thu Apr 13 20:29:14 CDT 2006

That seems like it should work. Thanks.

"maximillianx" <u1p2p3h4o5l6d72001@hotmail.com> wrote in message
news:ug$XqfXXGHA.1228@TK2MSFTNGP02.phx.gbl...
> For currently logged on users, try:
>
> (insert this somewhere after your strComputer declaration)
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
> "\root\CIMV2")
> Set colItems = objWMIService.ExecQuery("SELECT UserName FROM
> Win32_ComputerSystem")
>
> For Each objItem In colItems
> if objItem.username <> "" Then
> WScript.Echo "Logged on User: " & objItem.UserName
> Else
> wscript.echo "There are no users currently logged into " &
> strComputer
> End if
> Next
>
>
>
> "Valkan" <spam#npspam.com> wrote in message
> news:lq-dnR9lqcIRZqfZnZ2dnUVZ_umdnZ2d@comcast.com...
>>I have a VB script that writes a list of installed applications to a text
>>file that is named the computername.
>>
>> It works okay except that it does not list the user, so it is difficult
>> and time consuming to find which users are assigned to those computers.
>>
>> Can someone help me and show what needs to be added (and where) for the
>> script to also write the name of at least the currently logged on user?
>> Ideally, it would also write the list of all the domain user profiles on
>> that computer (or the domain user profiles on that computer that have
>> been used in the last 30 days).
>>
>>
>> Here is the script that lacks that added functionality:
>>
>>
>>
>>
>> on error resume next
>>
>> Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
>> Set objNetwork = CreateObject("Wscript.Network")
>> strComputer = objNetwork.ComputerName
>>
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> Set objTextFile = objFSO.CreateTextFile("\\server\folder\folder\inv\" &
>> strcomputer & ".txt", True)
>>
>> strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
>> strEntry1a = "DisplayName"
>> strEntry1b = "QuietDisplayName"
>>
>> Set objReg = GetObject("winmgmts://" & strComputer & _
>> "/root/default:StdRegProv")
>> objReg.EnumKey HKLM, strKey, arrSubkeys
>>
>> For Each strSubkey In arrSubkeys
>> intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
>> strEntry1a, strValue1)
>> If intRet1 <> 0 Then
>> objReg.GetStringValue HKLM, strKey & strSubkey, _
>> strEntry1b, strValue1
>> End If
>> If strValue1 <> "" Then
>> objTextFile.WriteLine strValue1 & "¿ " & strcomputer & "¿"
>> End If
>> Next
>>
>> strKey2 =
>> "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
>> strEntry2a = "DisplayName"
>> strEntry2b = "QuietDisplayName"
>>
>> Set objReg = GetObject("winmgmts://" & strComputer & _
>> "/root/default:StdRegProv")
>> objReg.EnumKey HKLM, strKey2, arrSubkeys
>>
>> For Each strSubkey In arrSubkeys
>> intRet2 = objReg.GetStringValue(HKLM, strKey2 & strSubkey, _
>> strEntry2a, strValue2)
>> If intRet2 <> 0 Then
>> objReg.GetStringValue HKLM, strKey & strSubkey, _
>> strEntry2b, strValue2
>> End If
>> If strValue2 <> "" Then
>> objTextFile.WriteLine strValue2 & "¿ " & strcomputer & "¿"
>> End If
>> Next
>>
>> objTextFile.Close
>>
>>
>
>