Link to home
Start Free TrialLog in
Avatar of Glenn M
Glenn MFlag for United States of America

asked on

VB Script to Check if the OS is Windows XP, if so then continue..

Experts,

I need a VB script that will do a Check to see if the OS is any version Windows XP. If so, then continue with the printer install portion of the script. If NOT, then close.

Here is my printer portion:

Set WshNetwork = CreateObject("WScript.Network")
On error resume next
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Commercial Invoice Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Commercial Laser Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Office BoxTag Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Office Invoice Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Office Laser Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Back Office Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\OfficeTag"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Retail Front Invoice Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Scheduling Color Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Scheduling Invoice Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Scheduling Laser Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Tempe Laser Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Warehouse Office Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Warehouse Reciever Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Office Management Laser Printer"
WshNetwork.AddWindowsPrinterConnection "\\az1svr1\Front Desk Laser Printer"
WshNetwork.SetDefaultPrinter "\\az1svr1\Front Desk Laser Printer"
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Does the second example here help?
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Glenn M

ASKER

MartinLiss, I am not very Vb savy, so it doesn't help me. I actually need someone to write it for me. :)

billprew, it failed agaisnt the machine, I thing the WMI lookup isn't correct as it goes to zero.

RobSampson, I am trying to incorporate some of your previous solutions, I don't think I have it down yet.
Avatar of Glenn M

ASKER

OK,

I got it to work as long as the machine is XP, but ideally how can i get it to run a different part of the script of the wmi detects it is windows 7?

here is what I have so far:

strComputer = "."
 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select Caption From Win32_OperatingSystem")
 
For Each objItem in colItems
     strOS = objItem.Caption
Next
 
Set objShell = CreateObject("WScript.Shell")
If InStr(strOS, "XP") > 0 Then

Set WshNetwork = CreateObject("WScript.Network")
On error resume next
WshNetwork.AddWindowsPrinterConnection "\\AZPRINT\Tempe Office Laser"
WshNetwork.AddWindowsPrinterConnection "\\AZPRINT\TempeTag"
WshNetwork.AddWindowsPrinterConnection "\\AZPRINT\Tempe Fax Printer"
WshNetwork.AddWindowsPrinterConnection "\\AZPRINT\Tempe Color Printer"
WshNetwork.SetDefaultPrinter "\\AZPRINT\Tempe Fax Printer"

End If
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial