Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking OS before running script

Status
Not open for further replies.

MrPorky

IS-IT--Management
Aug 2, 2011
3
0
0
GB
Hi,

Is it possible for a script to check the OS Version before running the rest of the script? I only want this script to work on windows 7.

Please help!


 
Sure can. Check the registry

Code:
CONST WINDOWS_7 = "Windows 7"
set objShell = Wscript.CreateObject("Wscript.Shell")

strOS = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName")
if (inStr(strOS, WINDOWS_7) = 0) then
   msgbox "This computer is not running Windows 7.  Good Bye"
   wscript.quit
end if

'the rest of the script
...

-Geates


"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Hi Geates

Is there anyway for this message to appear for a number of seconds then dissapear?

Thanks
 
Have a look at the WshShell.Popup method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top