CallumCatterall Posted November 29, 2011 Posted November 29, 2011 (edited) 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? Thanks! Edited November 29, 2011 by CallumCatterall
Gatt Posted November 29, 2011 Posted November 29, 2011 I used this and its brilliant for logon scripts 0: http://www.kixtart.org/
featured_spectre Posted November 29, 2011 Posted November 29, 2011 (edited) Been a while since I have done VBSCRIPT but this may help! '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 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) *edit* Replace "batchfile.bat" with the location and name of your batch file. Edited November 29, 2011 by featured_spectre 1
featured_spectre Posted November 29, 2011 Posted November 29, 2011 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)
CallumCatterall Posted November 29, 2011 Author Posted November 29, 2011 (edited) 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) Wow! Thanks for the speedy reply, shall test it tomorrow. Thanks again! Edited November 29, 2011 by CallumCatterall
featured_spectre Posted November 29, 2011 Posted November 29, 2011 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
Arthur Posted November 29, 2011 Posted November 29, 2011 If you want to check the OS version from within the batch file itself, try this... LoginScript.cmd @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 )
plexer Posted November 29, 2011 Posted November 29, 2011 Apply a wmi filter to the gpo that runs the script. Ben
CallumCatterall Posted November 29, 2011 Author Posted November 29, 2011 Apply a wmi filter to the gpo that runs the script. Ben What would the query be for that? Thanks.
featured_spectre Posted November 29, 2011 Posted November 29, 2011 That would be done via group policy on your server
Arthur Posted November 29, 2011 Posted November 29, 2011 (edited) SELECT Version, ProductType from Win32_OperatingSystem WHERE Version LIKE '5.1.%' AND ProductType = '1' or SELECT Version FROM Win32_OperatingSystem WHERE Version < "6" ... or you could use GPP. Edited November 29, 2011 by Arthur 1
CallumCatterall Posted November 29, 2011 Author Posted November 29, 2011 SELECT Version, ProductType from Win32_OperatingSystem WHERE Version LIKE '5.1.%' AND ProductType = '1' ... or you could use GPP. Thanks, so just paste that in the WMI query box and all should be good? And this is so it'll just run on XP? Thanks again!
CallumCatterall Posted November 29, 2011 Author Posted November 29, 2011 Yes to both. Great! Just for future reference, is '5.1.%' the OS type? so if I wanted to create a WMI filter to just go on Windows 7 I would change it to '6.1.%'? Thanks.
Arthur Posted November 29, 2011 Posted November 29, 2011 Correct. Windows 7 is "6.1.%", but if for example you wanted to specifically target Windows 7 with SP1 you would replace the % symbol with the actual build number i.e. "6.1.7601" 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now