VBS Samples

HOME
UP
Object Model WSH

 

some VBS You can use in Your managed env....

Get OS Language and do something

Option Explicit

Dim objWMIService
Dim colItems
Dim strlanguage
Dim objItem

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem")

For Each objItem In colItems
strlanguage = objItem.OSLanguage
If strlanguage ="1033" Then
    MsgBox "Deutsch"
ElseIf strlanguage = "1031" Then
    MsgBox "English"
End If


Next

WScript.Echo strlanguage

Update SystemEnvironment Path Variable with VB-Script

'==========================================================================
' Set environment Path
' written and (c) 2004 by Wolfgang Zerzawy (zacky)
' This tool is freeware (donationware)
' but please notify me if you find it useful - webmaster(at)zacky.de
' DATE : 30.09.2004
'use xxx.vbs to insert path at the beginning
'use xxx.vbs /u to remove path
'==========================================================================
'Schaltet Überprüfung auf deklaration aller verwendeter Variablen ein
Option Explicit

'Errorhandler umleiten, damits nicht haengenbleibt
'On Error Resume Next

Dim argCount,instmode
instmode = "install"
argCount = Wscript.Arguments.Count
If argCount > 0 Then
    If InStr(1, Wscript.Arguments(0), "u", vbTextCompare) > 0 Then
        instmode = "uninstall"
    End If
End If

'"Objekt"variablen deklarieren
Dim WSHShell,WshSysEnv
'Pfadvariablen deklarieren
Dim strPath,NewPath
'Objekte referenzieren auf Variablen
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")

'Einlesen des aktuellen Sys-Environments (HKLM) in Variable
strPath = (WshSysEnv("PATH"))
'Variable ergänzen
newPath = "C:\Program Files\JavaSoft\JRE\1.3.1_02\bin;"

dim ret : ret = InStr (1,strPath , NewPath ,1)

If instmode = "uninstall" Then
    'uninstal
    If ret <> 0 Then
        strPath = Replace (strPath,NewPath,"")
        WshSysEnv("PATH") = strPath
    Else
        WScript.Quit(1)
    End If
Else
    'install
    If ret <> 0 Then
        WScript.Quit(1)

    Else
        strPath = NewPath & strPath
        WshSysEnv("PATH") = strPath
    End If
End If

WScript.Quit (0)


'=======================  END            ================================
 

 

WINNT:// Provider

see:

WinNT Provider

(c) by Wolfgang Zerzawy 07-Mai-08 12:11   

XING