myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


Operating system condition

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Scripting Technologies] >> VB Script >> Operating system condition Page: [1]
Login
Message << Older Topic   Newer Topic >>
Operating system condition - 9/8/2008 3:35:00 PM   
ghernandez211

 

Posts: 24
Score: 0
Joined: 5/15/2008
Status: offline
Hello, I need help on creating a script based off the operating system,
For example I have a program that I need to launch to the computers on my network but I dont want it to install on server in case someone login into one of them.
I have already created the execution for this within my login script,

This is what I have written to so far. This is a vb script that calls on the WMI, I want to execute something else from the result of what is called.

Option Explicit
'On Error Resume Next
Dim strComputer
Dim wmiRoot
Dim wmiQuery
Dim objWMIService
Dim colComputers
Dim objComputer
Dim strComputerRole
Dim strcomputerName
Dim strDomainName
Dim strUserName
strComputer = "."
wmiRoot = "winmgmts:\\" & strComputer & "\root\cimv2"
wmiQuery = "Select * from win32_computersystem"
Set objWMIService = GetObject(wmiRoot)
Set colComputers = objWMIService.ExecQuery _
   (wmiQuery)
For Each objComputer in colComputers
strComputerName = objComputer.name
strDomainName = objComputer.Domain
strUserName = objComputer.UserName

________________________________


For example down here I would like to create and IF and endif statements that if the criteria is met then execute this fuction .
Im pretty lost at this point and would like some help. Tried a couple of things but didnt work.

Post #: 1
RE: Operating system condition - 9/9/2008 4:28:04 PM   
rbennett806


Posts: 827
Score: 13
Joined: 6/14/2006
Status: offline
Well does this VBScript code snippet help?

Dim objWMI, colWin32_OperatingSystem, objWin32_OperatingSystem, strOS

Set objWMI = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colWin32_OperatingSystem = objWMI.ExecQuery("select * from Win32_OperatingSystem")
For Each objWin32_OperatingSystem In colWin32_OperatingSystem
   If IsNull(objWin32_OperatingSystem.CSDVersion) Then
       strOS = objWin32_OperatingSystem.Caption
   Else
       strOS = objWin32_OperatingSystem.Caption & " (" & objWin32_OperatingSystem.CSDVersion & ")"
   End If
Next
If strOS = "Text name you are looking for" Then
   wscript.echo "do whatever"
Else
   wscript.echo strOS
End If


(in reply to ghernandez211)
Post #: 2
Page:   [1]
All Forums >> [Scripting Technologies] >> VB Script >> Operating system condition Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.422