Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VBS WMI Script, komme mit Computernamen-Variablen nicht klar

Empfohlene Antworten

Hi,

ich benutze folgendes WMI Script, um an die installierte Software auf Netzwerkcomputern zu kommen. Das Script wird beim Systemstart ausgeführt und schreibt eine Textdatei auf ein Netzlaufwerk. Jetzt wollte ich nur den Dateinamen durch den jeweiligen Computernamen ersetzen, allerdings komm ich nicht wirklich weiter. Hab schon mit Systemvariablen wie %Computername% rumexperimentiert, bringt aber irgendwie nix.

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.CreateTextFile("X:\Inventarisierung\[COLOR="Red"]COMPUTERNAME[/COLOR].tsv", True)

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _

 ("SELECT * FROM Win32_Product")

objTextFile.WriteLine "Caption" & vbtab & _

"Description" & vbtab & "Identifying Number" & vbtab & _

"Install Date" & vbtab & "Install Location" & vbtab & _

"Install State" & vbtab & "Name" & vbtab & _

"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _

 & "Version"

For Each objSoftware in colSoftware

 objTextFile.WriteLine objSoftware.Caption & vbtab & _

 objSoftware.Description & vbtab & _

 objSoftware.IdentifyingNumber & vbtab & _

 objSoftware.InstallLocation & vbtab & _

 objSoftware.InstallState & vbtab & _

 objSoftware.Name & vbtab & _

 objSoftware.PackageCache & vbtab & _

 objSoftware.SKUNumber & vbtab & _

 objSoftware.Vendor & vbtab & _

 objSoftware.Version

Next

objTextFile.Close

Und dann gleich noch ne Frage: Wie kann ich viele TSV Dateien zu einer großen Excel Tabelle zusammenfügen? Also praktisch alle Datensätze direkt hintereinander schreiben? (Aber erst im Nachhinein, ich will trotzdem für jeden PC zusätzlich ne eigene Datei haben)

Danke schonmal! :)

Du musst die Variable auslesen:


'====================================================================

' Declarations

'====================================================================


Option Explicit

'On Error Resume Next


' Set WshShell

Dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell")


'====================================================================

' Variables

'====================================================================


Dim strComputerName: strComputerName = WshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )


'====================================================================

' Script

'====================================================================


MsgBox strComputerName

In deinem Beispiel dann:
Set objTextFile = objFSO.CreateTextFile("X:\Inventarisierung\" & strComputerName & ".csv", True) 

Gruss,

tester2k5

Danke, funktioniert jetzt!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.