Skriptdepot: Windows Scripting Host
Option Explicit
Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Domain = " & WshNetwork.UserDomain
WScript.Echo "Computer Name = " & WshNetwork.ComputerName
WScript.Echo "User Name = " & WshNetwork.UserName

Sleep (VBS):

WScript.Sleep Wartezeit in Millisekunden

Veraltet (WSHExtend.ocx muß installiert sein):
Set objWait = Wscript.CreateObject("WSHExtend.WinExt")
objWait:WSHWait Wartezeit in Millisekunden
Option Explicit
Dim MsgText

MsgText = time
WScript.Sleep 3000
MsgText = MsgText & vbNewLine & time
WScript.Echo MsgText
WScript.Quit

Verknüpfung erstellen (VBS):

Option Explicit
Dim objWshShell, objShortcut, strDesktop

Set objWshShell = WScript.CreateObject("Wscript.Shell")
  strDesktop = objWshShell.SpecialFolders("Desktop")

Set objShortcut = objWshShell.CreateShortcut(strDesktop & "\Notepad.lnk")
  objShortcut.TargetPath = "%SystemRoot%\system32\notepad.exe"
  objShortcut.WindowStyle = 1       '(1 = Normal Window ; 3 = Maximized ; 7 = Minimized)
  objShortcut.Hotkey = "Ctrl+Alt+E"
  objShortcut.IconLocation = "notepad.exe, 0"
  objShortcut.Description = "Shortcut to Notepad"
  objShortcut.WorkingDirectory = strDesktop
  ' objShortcut.Arguments = "C:\myFile.txt"
  objShortcut.Save

WScript.Echo objShortcut.FullName

MSDN SpecialFolders Property
MSDN CreateShortcut Method


Internet Explorer mit mehreren Seiten in Tabulatoren öffnen (ab IE 7):

Option explicit
Dim objIE, navOpenInBackgroundTab

Set objIE = WScript.CreateObject("InternetExplorer.Application")
navOpenInBackgroundTab = &h1000

With objIE
.Width = 750
.Height = 600
.Left = 100
.Top = 50
.visible = true
.Navigate2 "http://www.google.de"
.Navigate2 "http://www.lycos.de", navOpenInBackgroundTab
.Navigate2 "http://www.yahoo.de", navOpenInBackgroundTab
End With

Set objIE = nothing
navOpenInBackgroundTab = Null

blogs.msdn.com
Microsoft - Developer Network
Microsoft - Script Center


Total sinnloser Alarm:

Set WshShell = CreateObject("WScript.Shell")
For i = 1 to 12000
    For j = 1 to 50
        WshShell.SendKeys(chr(175))
    Next
    WshShell.SendKeys(chr(&hAD))
    For k = 1 to 3
        'WshShell.Run "%comspec% /c echo " & Chr(07), 0, True
        WScript.StdOut.Write(Chr(07))
        WScript.Sleep 200
    Next
    WScript.Sleep 500
Next

[http://www.nilpo.com/2008/11/windows-xp/mute-sound-volume-in-wsh/]


Update.Session:

Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
Wscript.echo searchResult.Updates.Count & " ausstehende Updates gefunden"

if searchResult.Updates.Count > 0 then
    Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
    For I = 0 to searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    updatesToDownload.Add(update)
    Next

    Set downloader = updateSession.CreateUpdateDownloader() 
    downloader.Updates = updatesToDownload
    wscript.echo "Download der austehenden Updates ..."
    downloader.Download()

    Set installer = updateSession.CreateUpdateInstaller()
    Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
    For I = 0 To searchResult.Updates.Count-1
        updatesToInstall.clear()
    set update = searchResult.Updates.Item(I)
    If update.IsDownloaded = true Then
      updatesToInstall.Add(update)
            installer.Updates = updatesToInstall
            wscript.echo ""
            wscript.echo "Installiere " & "(" & i+1 & "/" & searchResult.Updates.Count & ") " & update.title
            t1=now
            Set installationResult = installer.Install()
            t2=now
            wscript.echo "HResult: " & installationResult.HResult
            wscript.echo "RebootRequired: " & installationResult.RebootRequired
            wscript.echo "ResultCode: " & installationResult.ResultCode
            wscript.echo "Installationsdauer in Sekunden: " & datediff("s",t1,t2)
        else
            wscript.echo "Update " & update.title & " wurde nicht erfolgreich herunter geladen."
    End If
    Next
    Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
    wscript.echo "Reboot ..."
    wscript.sleep 5000
    For Each OpSys in OpSysSet
        OpSys.Reboot()
    Next
else
    cleanup = true
end if

WshShell.Run "C:\WINDOWS\system32\shutdown.exe /s /t 15"

Screen size // Write to Host :

vbsInterpreter = "cscript.exe"

Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
Set WScriptShell      = CreateObject("WScript.Shell")
Set ScriptingFSO      = CreateObject("Scripting.FileSystemObject")
Set StdOut            = ScriptingFSO.GetStandardStream(1)
Set StdErr            = ScriptingFSO.GetStandardStream(2)

Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController",,48)
For Each objItem in colItems 
    intHorizontal = objItem.CurrentHorizontalResolution 
    intVertical = objItem.CurrentVerticalResolution 

    WScript.StdOut.Write("text string to display")
    WScript.StdOut.Write "another string to display"
    WScript.StdOut.WriteLine "text string as single line"
    StdOut.WriteLine intHorizontal
    StdOut.WriteLine intVertical
    StdErrv.WriteLine "
Next
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License