Sign in to follow this  
Followers 0
mirrorshades

%PATH% variable of a remote machine?

14 posts in this topic

Subject more or less says it all. Anyone know a decent way to evaluate the %PATH% environment variable on a Windows box, remotely? (Like, in such a way that would be practical to script it and execute against a large number of machines at once.) I have banged my head on this for several hours now and have not come up with a useful solution... has to be able to run against a default install of the OS, not an option to install a third-party app.

And a follow up for extra points... Windows 2000/2003, anyone know a magical way to "fix" the upper limit of 1024 characters in the path? (Again, in a manner that would suit bulk maintenance instead of one at a time clickey-clicking.)

If anyone can provide a decent answer/solution for either or both questions, I will officially drink a beer in your honor.

0

Share this post


Link to post
Share on other sites

Copy the output of 'set %path%' or 'echo %path%'.

Edited by jabzor
0

Share this post


Link to post
Share on other sites

Well, er, yes.

But show me a way to do that on a remote box besides logging on and opening a command prompt. :)

0

Share this post


Link to post
Share on other sites

Yup. Doesn't work.

Problem is that it wants to expand the variable locally before passing it to the remote system.

Today I actually did find the registry key where the Path variable is stored, which is much easier to get at remotely.

0

Share this post


Link to post
Share on other sites

Isn't this Active Directory's realm? I don't think you'll find a way to query %PATH% on arbitrary Windows machines. A domain... that's another story.

0

Share this post


Link to post
Share on other sites

Yeah, I didn't mention. This is in a domain, and I am using an account with domain admin rights. (And, thus, local admin on the box itself.)

0

Share this post


Link to post
Share on other sites

Yeah, I didn't mention. This is in a domain, and I am using an account with domain admin rights. (And, thus, local admin on the box itself.)

Im not a coder, so this might be a bit too ugly for what you're trying to accomplish.

Could you have a startup script that runs "echo %path% >> path.txt" and have your script read the file? Or maybe have it save the output to a share on the server the script is running on?

0

Share this post


Link to post
Share on other sites

Problem with a startup script would be the need to restart the server. :)

Also, that's not very bulk-friendly since I would have thousands of files to sift through. I have found a workaround that gives me what I need... it doesn't look like there's an in-built way to get at it with 2000/2003. :(

0

Share this post


Link to post
Share on other sites

Problem with a startup script would be the need to restart the server. :)

Also, that's not very bulk-friendly since I would have thousands of files to sift through. I have found a workaround that gives me what I need... it doesn't look like there's an in-built way to get at it with 2000/2003. :(

if you have a network machine/drive you could just use

echo %computername% >> (whatever you want).txt 
echo %path% >> (whatever you want).txt
echo "" >> (whatever you want).txt

then it wont over write the file so it will just be one giant file with all of the paths like

blah1 
c:\windows\

blah2
c:\windows\

ect.

and im guessing they arent your machines as idk anyone that owns thousands of computers but a startup scirpt would work just add a line to delete it after it runs so they dont notice it. eventually probably a couple days you'll get all of them(the path variables). problem would be restarting/getting it on all of the machines you want to see the path on. but with set it would just rewrite the file, with echo it would just write to the file like a log.

o well you figured it out and what not.

Edited by dinscurge
-1

Share this post


Link to post
Share on other sites

Even though it's been done, I feel the need to respond to a couple points:

and im guessing they arent your machines as idk anyone that owns thousands of computers

Welcome to the Big Leagues. This is for my job, where I am in fact a part of a team that maintains several thousand servers. And, in fact, the company I work for is probably midsized technology-wise compared to some of the big behemoths out there (how many servers do you think IBM, Google, or Microsoft have running?).

but a startup scirpt would work just add a line to delete it after it runs so they dont notice it. eventually probably a couple days you'll get all of them(the path variables).

Well, again... these are servers, so they don't just restart every single day. In fact, it would be a Very Bad Thing if some of them did. There are some that only reboot 3 or 4 times a year under highly controlled conditions.

Also when considering servers (as opposed to desktop/workstation PCs), a startup script is not a reliable means to execute something since an interactive logon may happen rarely, if ever. We do have a tool that allows us to run arbitrary commands on-demand, so that part isn't an issue. (It was just a problem with getting the remote value locally.)

The network share idea is decent, but the problem there is that the network is so segmented there is no way to guarantee that our internal firewalls will allow Windows filesharing traffic from any given point to any other given point on the network.

Enterprise-level network administration is a peculiar beast; a lot of the conventional wisdom or best-practice guidelines either can't be practically adhered to or were beat down by middle and upper management politicking. It is a fascinating world for someone like me, who cut his teeth on smaller Mom and Pop type networks. :)

0

Share this post


Link to post
Share on other sites

yeah thats true. well you could have always scripted for the windows ftp client and upload the file but yeah still not really useable. so im guessing you have alot of different machines? as the same machines/models should all have the same path.

edit: it also didnt help i thought you were trying to get the path variable of a bunch of computers using your domain not the servers..

Edited by dinscurge
-1

Share this post


Link to post
Share on other sites
the same machines/models should all have the same path.

Well, no... it depends on what is installed on each one.

0

Share this post


Link to post
Share on other sites
the same machines/models should all have the same path.

Well, no... it depends on what is installed on each one.

yeah. guess you have a hodgepodge of machines with different hardware/os's.

-1

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