#28260 - 2002-09-03 02:04 PM
Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
Hi having some problems:
Running a script from Kholm / works perfect, thanks
OS W2k Kix 4.0.2.0
code:
$Index = 0 $Key = EnumKey($RootKey, $Index) While @Error = 0 $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf $RC = WriteProfileString("$WSInfoFile", "ProgramInfo", "$Num", "$Value") $Num = $Num + 1 EndIf $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop Return
The output looks like this
[ProgramInfo] 1. Ms office 2 and so on
*
I would like the out put like this
[ code: --------------------------------------------------------------------------------
[ProgramInfo] Ms Office,=Microsoft Office 2000 Resource Kit Tools and Utilities
--------------------------------------------------------------------------------
Regards \erik
|
Top
|
|
|
|
#28261 - 2002-09-03 02:24 PM
Re: Comma Seperation
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Might try using the actual registry KEY name in your INI file ... not too sure what other "short info" you could "go for" ...
code:
break on $WSInfoFile = ".\wsinfo.ini" $Num = 0 $RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" $Index = 0 $Key = EnumKey($RootKey, $Index) While @Error = 0 $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf $RC = WriteProfileString("$WSInfoFile", "ProgramInfo", "$Key", "$Value") $Num = $Num + 1 EndIf $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop exit 1
[ 03. September 2002, 14:25: Message edited by: Shawn ]
|
Top
|
|
|
|
#28262 - 2002-09-03 02:41 PM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
code:
[SoftWare] Ad-aware 5.71=Ad-aware 5.71 Adobe Acrobat 5.0=Adobe Acrobat 5.0 Branding=Branding Citrix ICA Client=Citrix ICA Client Compaq DMI Insight Web Based Agent=Compaq DMI Insight Web Based Agents Compaq Insight Manager 7 Version 3.1=Compaq Insight Manager 7 SP1 Compaq Management Agents=Compaq Management Agents Compaq Sizer 2.1 for MS Exchange 5.5=Compaq Sizer 2.1 for MS Exchange 5.5 expinst=Internet Explorer Exception Pack GFI LANguard Network Scanner_is1=LANguard Network Scanner 2.0 IEAK6=Microsoft IEAK 6 IEREADME=Internet Explorer Viktigt Intel® NetStructure(TM) VPN Client=Intel® NetStructure(TM) VPN Client JetFormFiller5.2.6=JetForm Filler Pro 5.2.6 JRE 1.3.1=Java 2 Runtime Environment Standard Edition v1.3.1 JRE 1.3.1_02=Java 2 körtidsmiljö, Standardversionen v1.3.1_02 KiXscripts Editor_is1=KiXscripts Editor 1.1 LANDesk Enhanced Package Builder=LANDesk Enhanced Package Builder
The numbers are gone but still need the "," separation.
Ex [SoftWare] Ad-aware 5.71=Ad-aware 5.71,Package Builder
\erik
|
Top
|
|
|
|
#28263 - 2002-09-03 02:44 PM
Re: Comma Seperation
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Try adding a comma to the $key...
code:
$RC = WriteProfileString("$WSInfoFile", "ProgramInfo", "$Key"+",", "$Value")
|
Top
|
|
|
|
#28264 - 2002-09-03 03:25 PM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
hallo still some problems
code:
Ad-aware 5.71,=Ad-aware 5.71 Adobe Acrobat 5.0,=Adobe Acrobat 5.0 Branding,=Branding Citrix ICA Client,=Citrix ICA Client
The comma is there, but its duplicating and I need it on one row ex code:
Ad-aware 5.71,=Ad-aware 5.71,Adobe Acrobat 5.0,=Adobe Acrobat 5.0
Is it possible
\erik
|
Top
|
|
|
|
#28265 - 2002-09-03 03:30 PM
Re: Comma Seperation
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You can not use WriteProfileString if you want one row.
Look into using WriteLine() instead.
|
Top
|
|
|
|
#28266 - 2002-09-03 03:34 PM
Re: Comma Seperation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
$c=chr(44) $=Writeprofilestring("$logon\inventory\@year @month Hardware.csv","Hardware Inventory","@wksta","$c@userid$c$dept$c$Make$c$Model$c$Case$c$SerNo$c$Asset$c$Biosv$c$CPUsp$c$hdGB$c$hdmbfr$c$dimm0$c$dimm1$c$dimm2$c$modem$c$location$c$city")
|
Top
|
|
|
|
#28267 - 2002-09-03 03:47 PM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
Ok, output and structure of ini file
code:
[SM Inventory File] WsName=GOTLANDIC1 OSType=WinXP IEVer=6 Date=2002/09/02 Time=16:03:49 UserID=Administrator Comment=Built-in account for administering the computer/domain Privilege=ADMIN Software=Ad-aware 5.71,Adobe Acrobat 5.0,Branding,Citrix ICA Client,Compaq DMI Insight Web Based Agents,Compaq Insight Manager 7 SP1, Compaq Management Agents,Compaq Sizer 2.1 for MS Exchange 5.5,Internet Explorer Exception Pack,LANguard Network Scanner 2.0,Microsoft IEAK 6, Internet Explorer Viktigt,Intel® NetStructure(TM) VPN Client, JetForm Filler Pro 5.2.6,Java 2 Runtime Environment Standard Edition v1.3.1
This is the way I want it, so I can import it in an *.mdb file.
Can I use WriteProfileString i the other "sections"
Radimus, how can I use this with multiple program entrys ?
\erik
Any Ideas ?
{edit: Bullock} Broke long line to improve readability. [ 03. September 2002, 16:22: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#28268 - 2002-09-03 03:53 PM
Re: Comma Seperation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
change the "Hardware Inventory","@wksta" values to "SM Inventory File","Software"
|
Top
|
|
|
|
#28269 - 2002-09-03 03:53 PM
Re: Comma Seperation
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
In the code listed above that loops through the software, change the WriteProfileString to a variable and append each value until the loop ends. Then use WriteProfileString to write the software entry.
$Software = Software + ","
end loop
$Software = Left($Software,Len($Software)-1) WriteProfileString($file, $Section, "Software", $Software) [ 03. September 2002, 15:54: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#28270 - 2002-09-03 03:56 PM
Re: Comma Seperation
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
however, I would make 3 files: Hardware.csv Software.csv UserInfo.csv
If you can in your environment, put them is a central location and have everyone update central files.
if you name the ini files as CSV, then you can quickly open it in excel
|
Top
|
|
|
|
#28271 - 2002-09-03 04:02 PM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
code:
;--------------------------------- ; Extract Uninstall options (Installed programs) ;--------------------------------- $Num = 1 $RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" GoSub GetProgInfo $RootKey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" GoSub GetProgInfo
:Proginfo
code:
$Index = 0 $Key = EnumKey($RootKey, $Index) While @Error = 0 $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf $RC = WriteProfileString("$WSInfoFile", "ProgramInfo", "$Num", "$Value") $Num = $Num + 1 EndIf $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop Return
Getting a bit confused. Here Is the Original Code
What should I do ?
BTW: Radimus, why 3 files \erik [ 03. September 2002, 16:44: Message edited by: cellnet ]
|
Top
|
|
|
|
#28272 - 2002-09-03 04:24 PM
Re: Comma Seperation
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I am thinking that you want to loop throught the software and gather the data and then write the data after the loop ends. This yields one line in stead of writing after every key (Multiple lines).
Code quickly edited and not tested. code:
$Index = 0 $Key = EnumKey($RootKey, $Index) While @Error = 0 $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf $Value2 = "" + Value2 + "," + $Value EndIf $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop $Value = substr($Value2 ,2) $RC = WriteProfileString("$WSInfoFile", "ProgramInfo", "Software", "$Value")
Return
[ 03. September 2002, 16:25: Message edited by: Howard Bullock ]
|
Top
|
|
|
|
#28273 - 2002-09-03 04:47 PM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
sorry, forgot the $root key
Se updated post "original code"
Out put of latest script
: code:
[ProgramInfo] Software=alue2,Microsoft Office 2000 Resource Kit Tools and Utilities
Seems like we are closing in, but a lot of entries are missing
Thanks for the patient
\erik
|
Top
|
|
|
|
#28274 - 2002-09-03 05:07 PM
Re: Comma Seperation
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Put a print "? $Value ? $Value2" in your loop and just before the WriteProfileString to verify that you are collecting the data and that we are not loosing it somehow.
|
Top
|
|
|
|
#28275 - 2002-09-05 10:57 AM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
Hallo, thanks for the help, heres a little update.
I trashed the inventory file, and focused on a db connection.
It became a little mix between diffrent authors, thanks to shawn, radimus sealeapard and others.
The bit we were discussing here about installed programs, work out finally
code:
; Installed Programs
Function GetUninstallInfo() dim $Index, $Key, $RC, $Value, $RootKey dim $progs[0] $Index = 0
$RootKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$Key = EnumKey($RootKey, $Index) While @Error = 0 ReDim PRESERVE $progs[$Index] $RC = EnumValue($RootKey + $Key, 1) If @Error = 0 $Value = ReadValue($RootKey + $Key, "DisplayName") If $Value = "" $Value = ReadValue($RootKey + $Key, "QuietDisplayName") If $Value = "" $Value = $Key EndIf EndIf Else $Value = $Key EndIf $progs[$Index] = $Value $Index = $Index + 1 $Key = EnumKey($RootKey, $Index) Loop $GetUninstallInfo = $progs EndFunction
$array = GetUninstallInfo() $i=0 $divider = "," for each $item in $array $ProgramInfo = $ProgramInfo + $item $Programinfo = $Programinfo + $divider $i = $i +1 next
$Recordset.Fields("Program").value = $programinfo
tricky with the "," bit but finally...
regards \erik
|
Top
|
|
|
|
#28277 - 2002-09-05 11:10 AM
Re: Comma Seperation
|
cellnet
Starting to like KiXtart
Registered: 2002-02-26
Posts: 115
Loc: Sweden
|
benefits ?
running kix 4.0.2.0
\erik
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 202 anonymous users online.
|
|
|