I used this and its brilliant for logon scripts 0:
Hi, we currently have a login script which is needed for our XP environment but isn't needed for our new Windows 7 machines, is there a way to only run the script if the machine is XP? The script is a login script that is a .cmd that runs an application on logon if that helps?
Last edited by CallumCatterall; 29th November 2011 at 08:43 PM.
Been a while since I have done VBSCRIPT but this may help!
This will work when running W7 and XP and it will slot nicely in. If it doesn't find Windows XP, it won't run the batch file (tested on my home network)Code:'OS is Windows XP 'with at least SP2 or higher If InStr(strOSLongName, "XP") > 0 _ And intSPMajorVersion >= 2 _ ' Do load up script here dim shell set shell=createobject("wscript.shell") shell.run "batchfile.bat" set shell=nothing End If
Replace "batchfile.bat" with the location and name of your batch file.
Last edited by nephilim; 29th November 2011 at 08:34 PM.
D'oh - completely misread the OP
Not to worry, my vbscript should slot nicely in and in theory have no issues (tried on my home network of an xp laptop, my w7 laptop and windows server 2k8r2)
Not to worry, if it doesn't work let me know. Like I said it works fine on my home network (of a couple of machines) so how well it will do on a large scale I don't know.
And as for the speediness..thats what we are known for
If you want to check the OS version from within the batch file itself, try this...
Code:@echo off :: Get Windows version numbers FOR /f "tokens=2 delims=" %%G IN ('ver') DO (Set VERSION=%%G) FOR /f "tokens=2,3,4 delims=. " %%G IN ('ECHO %VERSION%') DO (Set MAJOR=%%G& Set MINOR=%%H& Set BUILD=%%I) IF "%MAJOR%" GEQ "6" ( :: If OS is Vista/7 or newer do this... GOTO :EOF ) ELSE ( :: If OS is NOT Vista/7 (i.e. XP) do this... START "" %SystemRoot%\System32\Calc.exe )
Apply a wmi filter to the gpo that runs the script.
That would be done via group policy on your server
orCode:SELECT Version, ProductType from Win32_OperatingSystem WHERE Version LIKE '5.1.%' AND ProductType = '1'
... or you could use GPP.Code:SELECT Version FROM Win32_OperatingSystem WHERE Version < "6"
Last edited by Arthur; 29th November 2011 at 09:39 PM.
Yes to both.
There are currently 1 users browsing this thread. (0 members and 1 guests)