Advertisement

04.21.2008 at 03:00AM PDT, ID: 23338972
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

How to  my *.vbs script to save in *.txt file

Asked by vilig in VB Script

Tags: , , ,

Hello, I am developing programs in labview, but to get data from computers I have to use vbs scripts.
I need data of installed software on domain computers.(Till now i used psinfo method in cmd, but it is very slow)
So, after few weeks of searching on internet I come to this two scripts:

In cmd i write command to start:   cscript admin.vbs

1.script (admin.vbs)
`with this script I run second script (installed.vbs) with domain admin privileges, without to be questioned for password with extra window. I allso  set here for which computer on network I need data.

set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas /user:administrator@mydomainname""cscript.exe C:\Users\vilig\Desktop\installed.vbs nameofmynetworkcomputer """
WScript.Sleep 100
WshShell.Sendkeys "mydomainpassword~"

2.script (installed.vbs)

` with this script i get data of installed software on the network computer(specifeided in admin.vbs)
 ' Script author: Torgeir Bakken
sComputer = WScript.Arguments.Item(0)
wscript.echo InstalledApplications(sComputer)
Function InstalledApplications(node)
 Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
 Set oRegistry = _
  GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
  & node & "/root/default:StdRegProv")
 sBaseKey = _
  "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
 iRC = oRegistry.EnumKey(HKLM, sBaseKey, arSubKeys)
 For Each sKey In arSubKeys
  iRC = oRegistry.GetStringValue( _
   HKLM, sBaseKey & sKey, "DisplayName", sValue)
  If iRC <> 0 Then
   oRegistry.GetStringValue _
    HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
  End If
  If sValue <> "" Then
   InstalledApplications = _
    InstalledApplications & sValue & vbCrLf

  End If
 Next

End Function

This data i get only to cmd window, but i need them in the *.txt file, to work further with them in the labview.
I can get to *.txt file if i manually start installed.vbs script in cmd with the command:
cscript installed.vbs nameofmynetworkcomputer >c:\soft.txt
But this is not started with domain admin privileges.(i get this data because i have the same user on the network computer)

so, the script shuld write *.txt file by itself. i tried some lines with:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\software.txt", True)
but never get data in the file.

because vbsscripting is not may mothers language i ask you:
How to save cmd output to *.txt file within the script (please show me what and where should be some lines)?
Is there posible to scan for all domain computers with this script?
Start Free Trial
[+][-]04.21.2008 at 03:56AM PDT, ID: 21400287

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Script
Tags: Microsoft, vbs script, vbs script, ie7
Sign Up Now!
Solution Provided By: merowinger
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628