Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: List add and remove programs

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,54859
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: List add and remove programs
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 2 [3]
Login
Message << Older Topic   Newer Topic >>
 RE: List add and remove programs - 1/10/2008 9:16:01 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Try changing this line:

Set OutFile = fso.OpenTextFile(sFileName, 2, True)

to this:

Set OutFile = fso.OpenTextFile(sFileName, 8, True)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to aburt)
 
 
Post #: 41
 
 RE: List add and remove programs - 1/10/2008 10:37:08 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Hey Ebgreen,
 
That actually gave me output in my text file.  But with scripting. There must be some law that says nothing you do is going to be easy.
 
 
The output gives me all 301 applications whereas my orginal list only had 201 applications.
 
 
 
 
 
 
Here where it list 201 apps
 

*************************************
WScript.Echo MisApp
Function MisApp
Dim arrApp()
intSize = 0
For Each strItem In Split(GetAddRemove(sComp), vbCrLf)
    If InStr(strBaseAppList, strItem) <= 0 Then
   ReDim Preserve arrApp(intSize)
     arrApp(intSize) = strItem
     intSize = intSize + 1
    End If
   Next
 For i = 0 to Ubound(arrApp)
   a = a + 1
   Applic = arrApp(i)
  
'******************************* When I run this script I get a list of all applications missing from baseimage.txt

   WScript.Echo "Machine vXYZ is missing " & a & " " & Applic
      Next
 
End Function

***********************************************



However if I run this it list 301 apps basically all application on the local system

Function MisApp
Dim arrApp()
intSize = 0
For Each strItem In Split(GetAddRemove(sComp), vbCrLf)
    If InStr(strBaseAppList, strItem) <= 0 Then
   ReDim Preserve arrApp(intSize)
     arrApp(intSize) = strItem
     intSize = intSize + 1
    End If
   Next
 For i = 0 to Ubound(arrApp)
   a = a + 1
   Applic = arrApp(i)
  
'******************************* When I run this script I get a list of all applications missing from baseimage.txt

         'WriteFile "Machine vXYZ is missing " & a & " " & Applic, sFileName
 Next
 
End Function




Attachment (1)

(in reply to ebgreen)
 
 
Post #: 42
 
 RE: List add and remove programs - 1/11/2008 12:19:34 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Ebgreen

I am very curious to know why changing


Set OutFile = fso.OpenTextFile(sFileName, 2, True)

to this:

Set OutFile = fso.OpenTextFile(sFileName, 8, True)

Helps me to see output in the text file. 

(in reply to aburt)
 
 
Post #: 43
 
 RE: List add and remove programs - 1/11/2008 12:23:47 AM   
  twilliamsen

 

Posts: 184
Score: 0
Joined: 1/18/2007
Status: offline
take out the Option Explicit and see what the error is.

(in reply to aburt)
 
 
Post #: 44
 
 RE: List add and remove programs - 1/11/2008 12:29:03 AM   
  ehvbs

 

Posts: 2025
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi aburt,

straight from the docs:

object.OpenTextFile(filename[, iomode[, create[, format]]])

Arguments

[...]
iomode
Optional. Can be one of three constants: ForReading, ForWriting, or ForAppending.

[...]
ForReading
1
Open a file for reading only. You can't write to this file.

ForWriting
2
Open a file for writing.

ForAppending
8
Open a file and write to the end of the file.

Hi twilliamsen,

what has "Option Explicit" to do with failing to write/append to file?

(in reply to twilliamsen)
 
 
Post #: 45
 
 RE: List add and remove programs - 1/11/2008 12:47:45 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
ehvbs

I understand that 8 is append.  I just dont understand why 2  is not working. 

(in reply to ehvbs)
 
 
Post #: 46
 
 RE: List add and remove programs - 1/11/2008 1:08:54 AM   
  ehvbs

 

Posts: 2025
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi aburt,

because the file used in ForWriting mode will be written to at the start each time:


      

output:


      

Regards

ehvbs

(in reply to aburt)
 
 
Post #: 47
 
 RE: List add and remove programs - 1/11/2008 1:39:53 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Ok I think I get it.  do you have any idea why the output is giving me all applications in the text file instead of just the ones not listed in the base image?

(in reply to ehvbs)
 
 
Post #: 48
 
 RE: List add and remove programs - 1/11/2008 1:44:35 AM   
  ehvbs

 

Posts: 2025
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi aburt,

I have no idea, because I can't see how a change of the output target (console
vs. file) can change the (selection of the) data.

Sorry about that

ehvbs

(in reply to aburt)
 
 
Post #: 49
 
 RE: List add and remove programs - 1/11/2008 1:52:02 AM   
  aburt

 

Posts: 104
Score: 0
Joined: 12/4/2006
Status: offline
Im not sure if you have done this or not or if your even willing.

But can you run my script against your machine I have included the base image.txt file.

I just want to see if you get the same results.

(in reply to ehvbs)
 
 
Post #: 50
 
 RE: List add and remove programs - 1/13/2008 7:34:15 AM   
  ehvbs

 

Posts: 2025
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi aburt,

As we now have to talk about "willing" -

I posted a 40 line script (15 of which I took from your script)

    http://www.visualbasicscript.com/fb.aspx?m=54029

with detailed description about its usage. It does everything you
need to determine and log the non-standard software on a computer.
You ignored it completely. (Other than Meg, I don't mind   such behaviour;
I can understand that "starting afresh" isn't attractive  to a person having
to deliver a script ASAP.)

I told you many times that your script is mess. You acknowledged that
but didn't do anything about it.

I answered more than one very basic question of yours; even adding
demo scripts to show what is plainly written in the Docs.

Your vague statements about what you did and what you got make it
very hard to diagnose your problem(s). E.g.: It's just not possible
that code like

    ....
    WScript.Echo ...
    ....

will output "all the lines of the (Apps missing from baseimage.txt)"
AND code solely changed to

    ....
    WriteFile ...
    ....

(provided the IO mode was set to ForAppending in that function) will
give "all 301 applications whereas my orginal list only had 201 applications".
You changed something else in between - an how should I know about that?

Nevertheless, I stepped thru a slightly modified version of the code you
posted in

  http://www.visualbasicscript.com/fb.aspx?m=55190

and found out, that

  If WriteFile(MsiApp, sFileName) Then
  ==>
  If WriteFile( MisApp(), sFileName ) Then

branches into the function where the comparison

  If InStr( strBaseAppList, strItem ) <= 0 Then

is done before the line

  strBaseAppList = oFSO.OpenTextFile("E:\NEW DIR$\Scripts\Add Remove Programs\baseimage.txt").ReadAll()

loads the file. So strBaseAppList is "" in MisApp(). Must I add: Nothing can be
found in an empty string? Must I add: The "WScript.Echo" version of script couldn't
have found anything in an empty string either?

So move

Dim strBaseAppList
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
strBaseAppList = oFSO.OpenTextFile("E:\NEW DIR$\Scripts\Add Remove Programs\baseimage.txt").ReadAll()

before the call to MisApp() or - much better - rework the structure/logic/layout
of your script in a way that makes it decent.

Regards (luck doesn't help here anymore)

ehvbs

(in reply to aburt)
 
 
Post #: 51
 
 
Page:  <<   < prev  1 2 [3]
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: List add and remove programs Page: <<   < prev  1 2 [3]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts