I'm looking for some help with the environment variable %COMPUTERNAME%. It is working in my script as a means to name a file after the local host name. At another point I am using the script to build a folder in a different directory over the network (to a mapped drive) and I need to name the folder the local host name of the original computer. This may not make sense but I will provide an example below:
Comp1 = BobPC
Comp2 = JakePC
I am making a zip file on BobPC, which is then being copied over to JakePC, but I need this file to be copied into a directory like... C:\CopiedFiles\BobPc because this script will be run on many computers and each of them needs a folder where the files will be located named after the computer it came from.
I hope this makes sense.
Right now I can make it build a folder just fine but it names it the name of "JakePC" obviously because I am using the environment variables to grab the local host name.
My question basically is how can I go about telling it to name the folder after the the original computer?
If you have any questions let me know, I will be more than happy to explain because I know that I might not be making much sense.
%COMPUTERNAME%environment variable. That variable will be always the local host name where the source files are, and since scripts will always run locally. If the script is run on "JakePC", then it will produce a folder named "JakePC" on remote computer. Just like what you already state in the post. Or are your trying to name the folder using the remote host name?Z:\CopiedFiles\BobPCassumingZ:is mapped to\\JakePC\DriveC. If that path isn't already present, you'll have to create it first. One subfolder at a time if necessary. Otherwise, you'll get an error.