Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

I'm trying to set an environment variable through GPO, and I'm hitting a wall.

 

The idea is that I set the variable and the desktop background is set to the same one as the login screen...

 

At first I was using "wmic desktopmonitor get screenheight" [and screenwidth] so that I could use "background%height%x%width%.jpg" as the desktop.

 

But it didn't work...

 

 

I'm now poking "for /f "tokens=2 delims==" %%a in ('wmic desktopmonitor get ScreenHeight /value') do set hres=%%a" which works for a fraction of a second... then sets hres as nothing.

 

I think it's picking up the second output.

 

Is there a way of getting it to only accept numbers? I've tried adding in "echo %%a| findstr /r '^[1-9][0-9]*$'" but it looks like it crashes CMD.

 

 

[And yeah, I'm surprisingly motivated when I'm trying to be lazy...]

Posted

Ok... What's wrong with this:

 

for /f "tokens=2 delims==" %%a in ('wmic desktopmonitor get screenheight /value') do (if /i %hres% LSS %%a (set hres=%%a))

 

Because it just sets hres as 900.

 

This is what I get from "wmic desktopmonitor get screenheight"

 

C:\windows>wmic desktopmonitor get screenheight /value




ScreenHeight=




ScreenHeight=1080




ScreenHeight=900

 

 

I don't get it... 1080 is more that 900, so why is resetting the variable?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...