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.Shel
l")
WshShell.Run "runas /user:administrator@mydoma
inname""cs
cript.exe C:\Users\vilig\Desktop\ins
talled.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(sCom
puter)
Function InstalledApplications(node
)
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oRegistry = _
GetObject("winmgmts:{imper
sonationLe
vel=impers
onate}!\\"
_
& node & "/root/default:StdRegProv"
)
sBaseKey = _
"SOFTWARE\Microsoft\Window
s\CurrentV
ersion\Uni
nstall\"
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.Fi
leSystemOb
ject")
Set objTextFile = objFSO.CreateTextFile("c:\
software.t
xt", 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