Glenn M
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.Netw ork")
On error resume next
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Commercial Invoice Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Commercial Laser Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Office BoxTag Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Office Invoice Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Office Laser Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Back Office Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\OfficeTag"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Retail Front Invoice Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Scheduling Color Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Scheduling Invoice Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Scheduling Laser Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Tempe Laser Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Warehouse Office Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Warehouse Reciever Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Office Management Laser Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\az1svr1\Front Desk Laser Printer"
WshNetwork.SetDefaultPrint er "\\az1svr1\Front Desk Laser Printer"
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.Netw
On error resume next
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.SetDefaultPrint
Does the second example here help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There's a WMI method shown here:
https://www.experts-exchange.com/questions/24194249/VBScript-based-on-OS-version.html
Regards,
Rob.
https://www.experts-exchange.com/questions/24194249/VBScript-based-on-OS-version.html
Regards,
Rob.
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.
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.
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("S elect Caption From Win32_OperatingSystem")
For Each objItem in colItems
strOS = objItem.Caption
Next
Set objShell = CreateObject("WScript.Shel l")
If InStr(strOS, "XP") > 0 Then
Set WshNetwork = CreateObject("WScript.Netw ork")
On error resume next
WshNetwork.AddWindowsPrint erConnecti on "\\AZPRINT\Tempe Office Laser"
WshNetwork.AddWindowsPrint erConnecti on "\\AZPRINT\TempeTag"
WshNetwork.AddWindowsPrint erConnecti on "\\AZPRINT\Tempe Fax Printer"
WshNetwork.AddWindowsPrint erConnecti on "\\AZPRINT\Tempe Color Printer"
WshNetwork.SetDefaultPrint er "\\AZPRINT\Tempe Fax Printer"
End If
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("S
For Each objItem in colItems
strOS = objItem.Caption
Next
Set objShell = CreateObject("WScript.Shel
If InStr(strOS, "XP") > 0 Then
Set WshNetwork = CreateObject("WScript.Netw
On error resume next
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.AddWindowsPrint
WshNetwork.SetDefaultPrint
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.