Jump to content



Photo

Change DSN Server Entries by User?


  • Please log in to reply
6 replies to this topic

#1 KeithAbbott

KeithAbbott

    Seeker

  • New Members
  • 4 posts

Posted 25 April 2012 - 10:51 PM

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?





#2 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,085 posts

Posted 26 April 2012 - 12:21 PM

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. ;)
J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF

#3 guinness

guinness

    guinness

  • MVPs
  • 10,317 posts

Posted 26 April 2012 - 12:28 PM

Also look at the netsh commands in Windows too.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_DesktopDimensions()_DisplayPassword()_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()_GUISetIcon()_Icon_Clear()/_Icon_Set()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_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()_StringIsValid()_StringReplaceWholeWord()_StringStripChar()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()AutoIt SearchAutoIt3 PortableAutoItWinGetTitle()/AutoItWinSetTitle()CodingFileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIGetBkColor()LockFile()PasteBinSciTE JumpSignature CreatorWM_COPYDATAMore Examples...Updated: 11/04/2013


#4 KeithAbbott

KeithAbbott

    Seeker

  • New Members
  • 4 posts

Posted 26 April 2012 - 09:45 PM

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

#5 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,085 posts

Posted 27 April 2012 - 12:14 PM

I would think putting it in the user's startup folder would do the trick; it should run as soon as they log in.
J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF

#6 KeithAbbott

KeithAbbott

    Seeker

  • New Members
  • 4 posts

Posted 28 April 2012 - 01:47 AM

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.

#7 JLogan3o13

JLogan3o13

    Down to 98

  • MVPs
  • 2,085 posts

Posted 28 April 2012 - 11:43 AM

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?
J.I spent 10 minutes reviewing code and thinking "What kind of drugs is this guy on?" before realizing it was something I wrote.My Scripts:Include Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, SCCM 2007 Front End, Windows Firewall UDF




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users