2

As part of a network engineering team, one of the common problems we have is lack of access to CLI tools when we are diagnosing various windows machines

While the perfect world is to get the server and desktop teams to install these utilities on all systems, the real world is that it won't happen for all machines. My idea: give team members a read-onlyNote 1 USB that they can insert into machines so they can diagnose issues, even if that windows machine can't mount a corporate network share.

However, this plan depends on yet another activity... when the USB is plugged into a windows machine, I need whatever drive letter is assigned to somehow be put into the Windows %PATH% (hopefully automatically). How can I do this from resources installed on the USB itself?


Note 1: Read-only to avoid the obvious issues with security and virus infections

Mike Pennington
  • 8,305
  • 9
  • 44
  • 87
  • I edited your title to more accurately reflect the problem at hand, since it seems *what* is on the USB stick is less important. – MDMarra Jul 24 '12 at 18:47
  • Why do you need the drive letter in the `%PATH%` variable? Wouldn't it be easier to open your command window from the USB stick? (So it's at `E:` (or whatever) instead of `C:\[userprofilepath]` or `%systemroot%`?) – HopelessN00b Jul 24 '12 at 20:39
  • No it's not easier to open from the command window... Why should people have to depend on being in the same directory as the USB? What if you need to `cd` around the machine in question and you aren't in the USB root? – Mike Pennington Jul 24 '12 at 20:51

1 Answers1

3

You can use the setx command to set the PATH that will be given to newly opened shells. Combine that with an autorun batch file and you should be in good shape. You will have to reverse the procedure before ejecting the drive though.

As an alternative, have a cmdln.bat on the drive that opens a shell with environment configured how you would like it. That way there are no changes to the target machine.

Chris Nava
  • 1,147
  • 1
  • 7
  • 9
  • How does the autorun batch file know what drive letter has been assigned to the USB? – Mike Pennington Jul 24 '12 at 19:40
  • Presumably, it would be the "current" drive letter when the autorun.bat is running. Try this method http://stackoverflow.com/questions/866623/how-do-i-test-the-current-drive-letter-in-a-batch-file – Chris Nava Jul 24 '12 at 20:42