Adding an host programmatically (name resolution under Windows) - winapi

I would like to programmatically add to Windows a name / IP association so that this name can be resolved locally. This does not have to be persisted between reboots.
The only way I now is to add an entry to the "hosts" file, but this feels hacky especially since I would like to automate this.
Is there any way to do this using a command-line tool or a Win32 API? Perhaps by addind an entry to Windows DNS cache or something similar?
Oh, and please state if this solution is Vista-compatible.
Regards.
Edit : Thanks, guy. Sadly, all of your answers indeed involve DNS or other servers. I was looking for a purely local solution which would work on a "standard" Windows installation. Such a thing does not seem to exist, though.

This page lists a bunch of scripts for doing various things with the DNS service, including adding a name to it. This seems to be part of the Windows Management Instrumentation system, which I'm afraid I don't know anything about.
EDIT: There is also this function, which says it can add records to the DNS. Not sure if that means that it actually modifies the DNS server's state, or if it talks about the local resolver. It also requires Windows 2000 Server or greater, so it might be too narrow.

Related

Windows registry key to prevent automatic drivers installation?

I'm looking for a simple method to prevent Windows Update from installing drivers automatically. Exactly these steps:
http://support.microsoft.com/kb/2500967
Is there any method to do these steps just by modifying registry keys? Or even by doing it with help of a simple bat file?
I've just found an answer. The key I was looking for is located here:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching]
"SearchOrderConfig"=dword:00000000
To add this values to our registry, we can use that command in our batch file:
REGEDIT /S NameOfOurRegFile.reg
I don't know of a registry key, but why not change the windows update to download, but not install. Then you can review the updates and use right-click-hide to hide the driver updates.
I like to see the driver updates because that lets me know that I might want to go to the vendor site to look at the real driver info and decide if I need it or not. I then only install the driver (from the vendors site) if there are changes I need.
And since I have hidden it in update, I don't get bothered again until a new driver comes out.
Just a thought (vs. hacking your registry.)
One other consideration. In some cases, a registry hack might have some side consequences that confound you late when you can't figure out why something you thought should work, doesn't. Most support options don't consider registry hacks when trying to figure out why something doesn't work...
I can't comment, so here are some things to consider.
What you want to do will possibly look very much like a virus that wants to prevent things from being fixed. So if you do find a way, I strongly encourage you to test it with a number of AV apps - and then register it with them so they don't add it later.
You do have an option to check the version of the drivers in use for given hardware items. Then, if your app sees a new driver, it can at least warn the user that a new driver was installed (and log that fact) and to roll the update back if they have problems.

How can I force mapped drive synchronization in MS Windows XP?

I searched, so hopefully this isn't already a posted question already.
Basically, when we have users connect to the network via VPN, even though the login script will run and map their network drives, their home share drive (in this case P:) does not reflect the network version and shows the "offline" version.
The problem is they don't see all their files, and of course don't know how to trigger synchronization. Of course ideally we would just turn it off and there would be no problem, but as most of you know, working in a corporate environment we're bound by the decisions of the guys in another department.
So, is there a way to trigger folder synchronization? OR is there a way to force Windows when mapping the drive to look to the network version? I tried the true switch on the mapnetworkdrive method of the WSHnetwork but no joy.
Found a simple solution, you can call "mobsync.exe /logon", closing thread.
Details from microsoft, their pages move around so this is just a search.

Localhost on windows 7 configuration issue

When I am making changes on my localhost, it is not working. I am on windows 7 but when I copy the file in which the changes were made, and try to execute them in Windows XP, its working. I as I asked someone who has a lot of knowledge on this and they said it is a configuration issue.
Someone else told me it was because of output caching, so I disabled everything and tried, even then there was no response. Can anyone tell me how do I go about it?
This was because of caching issue.
Navigate to Control Panel\All Control Panel Items\Administrative Tools\IIS Configuration Manager, select Output caching, then add new rule with follow parameters:
Insert types of files, you are changing(.aspx,.php) in File name extension field and simply unselect all types of caching. Then restart server and it should work now
I could hardly understand your word, so I think your very first task is to make sure you understand IIS and how to start troubleshooting.
Without a clearer description on the problem, nobody can provide you useful information on how to resolve it.
If you like, open a support case with Microsoft support team and talk to the support engineer about your issue.
http://support.microsoft.com

Mounting archives such as *.zips (work in kernel mode without drivers)

I was wondering if there was a way to make a *.dll that mounts archives in Windows without the need for installing drivers. I've tried mounting *.isos (and was successful), but I needed to install drivers, which was not something my intended audience wants to do (or can do). The other relevant alternatives were for Linux (fuse-zip) or dead projects (zipios++).
Something along the lines of this...http://mountziplibrary.codeplex.com/
Oh, and it'd be great if the solution was GPL v3'd or at least open source.
Thanks.
Have you looked at Dokan? It looks like a Windows equivalent to Fuse.
What you're describing is called an Installable File System (IFS). It theory you don't need a driver: implement a SMB server in application space, and let the existing kernel network client talk to that. It's just TCP/IP at that level.
The proper solution is indeed an IFS driver. Fundamentally, drives are objects in the kernel namespace. As such, the code for them should be part of the kernel, and an application never is.
There was a hobbyist project called WinFUSE once, which worked as an SMB server and redirected FS requests to your .NET code. But it's gone, as far as I know. Proper way is to use a driver-based approach. The driver can be installed and removed on-the-fly if the user has admin rights, and if he doesn't, installation of the application requires admin rights anyway. In Unix/Linux it's the same - you can't mount a disk (not saying about the driver now) if you are not an admin. Could I not mention that Callback File System is the only professional supported solution that lets you accomplish the task?
I've decided to Google around for some answers.
One of particular interest was zziplib. It's for C and transparently accesses archives, just like Windows does, treating it as an actual folder.
Of course, the other implementations given by users work too. This one just fit the bill for me.
Maybe this one helps you: ZLib

sync between local and virtual machine

I'm working on a windows platform and want to be able to auto sync my files one way 'on change' to my virtual windows or linux web server - also need to be able to filter file types. i can connect to the remote machine via network drives.
i'm ideally looking for a free, easy to set up solution - a commercial product that does what I need is called ViceVersa but its a little overkill and costs :)
Thanks
Josh
I'd use rsync - simple, easy to setup, and provides the filters you need. Also very low on bandwidth after the first pass.
Here is a link explaining how to get it working in Windows
Whilst rsync doesn't allow 'on-change' auto-syncing, it is very fast when it scans a sync'ed directory (even very large ones), so you could schedule a frequent sync to overcome this.
Edit: You could combine it with a program like this, to trigger an rsync on folder contents change. Cheaper than viceversa
For other users, its worth mentioning lsyncd, it will auto sync on changes between two machines (by default deferring to rsync). Will only work on Linux though, but if thats not a problem it works great.
It also seems that Sparkleshare has finally released some working code (Dropbox clone). Havent tried it myself but does cross-platform synching and you can setup your own server.

Resources