Hello!
I have about 75 offices all with slightly different configurations as far as how their network drives are. Some of the hosts are named building-office, building-server, building-manager, or just server.
Well I run a certain program that pulls files from that drive and transfers them to the local PC, which each employee will run via the network drive.
I really need a way to auto implement the network path as a variable, rather than after deploying it to each location having to first find the network path and then change the batch script's "servah" variable to that path.
I know NET USE will display active network drives (which each location has only one of)
Now is there a way for the batch to take the remote output and use it as an input for a variable?
I suppose that you could do this the hard way, it is possible after all. But why wouldn't you just have each site host a CName entry on their respective DNS that resolves to the correct path?
I'm sorry, but I'm not too well versed on what CName is.
Every location has an actual different name, plus the individuals there are much less than intelligent so we prefer to make things as simple as possible for them.
Say the location name is Jacksonville, each computer would be names Jacksonville1-9 with a Jacksonville-server or something of the like, and in case someone for whatever reason disconnects the network drive they can just type the address \\jacksonville-server and have their data drive...
Also, I can only imagine hosting a CName would require a slight manipulation of the entire configuration, which is incredibly time consuming for 75 stores of very slow computers, and I am not the one who initially implemented the system, so such a change would be out of my power.
When I think about it, it wouldn't be too much less time consuming to simply change the variable for each locations making 75+ different batches to distribute compared to the time I'm spending trying to figure this out, though at this point I would simply like to know for personal knowledge.
If the server is the same one that they authenticate on, i.e. where LDAP is hosted, then the name is stored in the local sessions environment block under 'LOGONSERVER'. So you would use the "GetEnvironmentVariable()" function to retrieve it: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683188(v=vs.85).aspx .
The problem with your intended approach (apart from the fact that you know something is wrong and you'd rather work around the problem the fix it outright) is that network shares are supposed to be transparent. So the WinAPI functions treat a network share the same way they would treat an actual disk partition. You could use "GetLogicalDriveStrings()" and "GetDriveType()" to determine what drives are network drives and grab your data via SMB from there. But you can't really get the network address of the remote machine that they are hosted on with that solution.
I'm a SysAdmin by the way, the fact that you don't know what a Canonical name is brings to question your qualification to be doing this in the first place.
Well I do not claim to be any kind of professional, and neither is the company I work for.
We are very basic low level computer techs. There is no actual "server." It is a comp with a basic operating system and a folder named "data" in C:\ that is shared to "everyone," and that drive is simply mapped from each workstation. The system we have in place is extremely basic, yet completely efficient for its purposes.
I apologize for my lack of knowledge and expertise, however I am making an effort to improve our system in any way possible without of course re implementing a new one which we do not have the time or resources for.
Perhaps if I asked the question in a much less complicated way.
Knowing there is only one, how can I grab the host name of a single shared drive on any (basic) network via command line and use that as a variable?
The company we provide support for is extremely successful, mostly due to their extreme lack of spending. They realize the necessary items to run their business and do not spend beyond their needs to operate at maximum efficiency. The support level my company provides is what is efficient for them.