Jump to content


Photo
- - - - -

%PATH% variable of a remote machine?


  • Please log in to reply
13 replies to this topic

#1 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 22 June 2009 - 08:16 PM

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.

#2 jabzor

jabzor

    hax?

  • Agents of the Revolution
  • 1,146 posts
  • Country:
  • Gender:Male
  • Location:Northern Elbonia, fighting the lefties

Posted 23 June 2009 - 02:56 AM

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

Edited by jabzor, 18 July 2009 - 10:03 AM.


#3 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 23 June 2009 - 10:35 PM

Well, er, yes.

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

#4 mecca_

mecca_

    DDP Fan club member

  • Members
  • 54 posts

Posted 24 June 2009 - 12:50 AM

Assuming you're talking about machines on a LAN, have you looked at psexec?

http://technet.micro...s/bb897553.aspx

You should be able to connect to other machines and execute "set %path%". Yes, it's a third party app but you only need to install it on the machine acting as the server.

Edited by mecca_, 24 June 2009 - 12:52 AM.


#5 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 24 June 2009 - 03:41 PM

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.

#6 Ohm

Ohm

    I could have written a book with all of these posts

  • Members
  • 3,209 posts
  • Gender:Male
  • Location:Maine, USA

Posted 24 June 2009 - 03:52 PM

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.

#7 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 24 June 2009 - 11:07 PM

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

#8 Lord Wud

Lord Wud

    SUPR3M3 31337 Mack Daddy P1MP

  • Members
  • 423 posts
  • Location:New Jersey

Posted 13 July 2009 - 11:59 AM

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?

#9 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 13 July 2009 - 09:59 PM

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

#10 dinscurge

dinscurge

    "I Hack, therefore, I am"

  • Members
  • 936 posts
  • Country:
  • Gender:Male
  • Location:the bunker

Posted 13 July 2009 - 10:36 PM

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, 13 July 2009 - 10:36 PM.


#11 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 14 July 2009 - 10:53 PM

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

#12 dinscurge

dinscurge

    "I Hack, therefore, I am"

  • Members
  • 936 posts
  • Country:
  • Gender:Male
  • Location:the bunker

Posted 14 July 2009 - 11:04 PM

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, 14 July 2009 - 11:05 PM.


#13 mirrorshades

mirrorshades

    aviatorglasses

  • Agents of the Revolution
  • 951 posts
  • Gender:Male

Posted 14 July 2009 - 11:25 PM

the same machines/models should all have the same path.

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

#14 dinscurge

dinscurge

    "I Hack, therefore, I am"

  • Members
  • 936 posts
  • Country:
  • Gender:Male
  • Location:the bunker

Posted 14 July 2009 - 11:28 PM

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.




BinRev is hosted by the great people at Lunarpages!