Sign in to follow this  
Followers 0
KeithAbbott

Change DSN Server Entries by User?

7 posts in this topic

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?

Share this post


Link to post
Share on other sites



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. ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Also look at the netsh commands in Windows too.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

I would think putting it in the user's startup folder would do the trick; it should run as soon as they log in.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0