Windows Script Host (WSH) facilitates developing scripts for Windows 10 using scripting languages such as Visual Basic.
a. Write down a visual basic script (hw3_yourlastname2.vbs) which will display the current user’s login name, computer name, domain name and user profile (home folder) in a message box
b. Write down a visual basic script (hw3_yourlastname3.vbs) which will list all the printers (including virtual ones such as Adobe Writer) and their assigned port(s) defined on your computer
1. Set objNetwork = CreateObject("Wscript.Network") Wscript.Echo "The current user is " & objNetwork.UserName Wscript.Echo "Computer Name is " & objNetwork.ComputerName Wscript.Echo "Domain Name is " & objNetwork.UserDomain Set objShell = CreateObject("WScript.Shell") userProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%") Wscript.Echo userProfilePath 2. strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colInstalledPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") For Each objPrinter in colInstalledPrinters Wscript.Echo "Name: " & objPrinter.Name Wscript.Echo "Location: " & objPrinter.Location Wscript.Echo "Default: " & objPrinter.Default Next
Get Answers For Free
Most questions answered within 1 hours.