Quantcast
Channel: Directory Services forum
Viewing all articles
Browse latest Browse all 31638

Create and update a system variable for the current site

$
0
0

Hello.

Sorry if this is the wrong forum for this, but I need some help with a system variable.

Imagine a user using hos laptop in London, hibernates it and takes a plane to Tokyo and continues there without a reboot. He just unlocks his laptop as it comes out of hibernate. I need to create and update a system-variable depending on which AD-site the client is located in. This variable has to update itself automatically depending on where the computer is located, and it can't require a reboot.

I have used GP Preference to create a system-variable named "CurrentSite" and I'm trying to set it's value to the current site in AD based on the clients IP-address. Something like the output from "nltest /dsgetsite" But here comes the challenge: I've created a .bat file like this

nltest /dsgetsite>c:\batch\currentsite.txt
set /p CurrentSite=<c:\batch\currentsite.txt
del c:\batch\currentsite.txt

but when I run it the output is this (There's a 1 and a 0 in the middle of the line now)
C:\Batch>nltest /dsgetsite 1>c:\batch\currentsite.txt
C:\Batch>set /p CurrentSite= 0<c:\batch\currentsite.txt
C:\Batch>del c:\batch\currentsite.txt
Also I'm not sure how to get rid of the "The command completed successfully" output and how that would interfere. The funny thing is that this has worked earlier but now it fails every time and I haven't touched the script.

The secnd challenge is to have this updated automatically. I've tried to set up an scheduled task using Group policy preferences which runs this batchfile whenever a user logs on or unlocks his workstation, but it looks like the triggers aren't working. Any suggestions?

also if anyone knows a better way to solve this, I'd love to hear it.

Thank you all in advance


Regards Per-Torben Sørensen



Viewing all articles
Browse latest Browse all 31638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>