KeithAbbott Posted April 25, 2012 Share Posted April 25, 2012 I'm looking for a way to set the DNS server on a Win7 workstation by user. So I would like the DSN server for userA to point to 1.1.1.1, and the DNS server for userB to point to 2.2.2.2. I would like it to automatically switch to the corresponding DNS server everytime the Windows "switch user" functionality is invoked. I would like this to happen as seamlessly as possible in the background. Any help/suggestions? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 26, 2012 Moderators Share Posted April 26, 2012 Hi, KeithAbbot. You can set this in the registry under HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParametersInterfaces. Find the key for your network adapters, and the value "NameServer". Check out RegRead and RegWrite in the Helpfile for ways to input this info. Try your hand at writing a script, and feel free to post what you have here if you run into any issues. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
guinness Posted April 26, 2012 Share Posted April 26, 2012 Also look at the netsh commands in Windows too. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
KeithAbbott Posted April 26, 2012 Author Share Posted April 26, 2012 Any suggestions on how to detect when the user has switched (e.g from UserA to UserB) so that the code can then change to the appropriate nameserver? Maybe this would need to be run as a service... Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 27, 2012 Moderators Share Posted April 27, 2012 I would think putting it in the user's startup folder would do the trick; it should run as soon as they log in. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
KeithAbbott Posted April 28, 2012 Author Share Posted April 28, 2012 Putting it in the startup folder would only execute upon initial log in for a given user. When a switch user event occurs (i.e. switching from UserA to UserB, when both users have previously established sessions), the entries in the startup folder are not re-executed. I need to be able to trigger an event any time a login or switch user happens. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 28, 2012 Moderators Share Posted April 28, 2012 If you're allowing Fast User Switching, you're going to run into problem, because the script process from User 1 will still be running. Is this a hard and fast requirement for your environment, or can you disable Fast User Switching to make users log off? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
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