Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Can I clean up by PATH. HP trashed it!  (Read 11283 times)

0 Members and 1 Guest are viewing this topic.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Can I clean up by PATH. HP trashed it!
« on: January 14, 2011, 09:06:32 PM »
My PATH variable looks terrible. Gots things in it that I have little idea where they came from . Looks like HP did it when I installed the 6550 which no longer works on my network, so I am going to remove all that @#@#$ software that nags me to buy more ink. NO! I am beck to using the old printer, that runs forever on cheap ink!

Meanwhile, is the a program or tool that will verify that my PATH is the way is should be?

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: Can I clean up by PATH. HP trashed it!
« Reply #1 on: January 15, 2011, 08:15:28 PM »
Geek: is the a program or tool that will verify that my PATH is the way is should be?

Doubt it, everyone's Path could be different.  Mine is:

c:\windows\;c:\windows\system32;c:\;c:\bat;C:\Program Files\Support Tools\;c:\cmdutils\


Your Path has to be set as you want it.
One good deed is worth more than a year of good intentions.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can I clean up by PATH. HP trashed it!
« Reply #2 on: January 15, 2011, 08:34:18 PM »
Thank you. I was hoping there was a thing that would clean up the path and remove duplicates or dead directories.

Anyhow, I just removed anything the said HP in it. The printer doesn't work anymore anyhow. So far the system works OK.

BTW,  I got a e-mail for people that bought HP printers recently. Something about a class action lawsuit. Can I sue them for messing with my PATH? Like mental anguish?

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: Can I clean up by PATH. HP trashed it!
« Reply #3 on: January 16, 2011, 01:45:16 AM »
Geek: Can I sue them for messing with my PATH? Like mental anguish?

Sure thing, probably cost you $100,000 to possibly win $50,000.  Ever heard of a class action by the little guys against a big guy which came out in favor of the littlies?

Keep us informed - might take ten or so years to get before a judge.
One good deed is worth more than a year of good intentions.

Salmon Trout

  • Guest
Re: Can I clean up by PATH. HP trashed it!
« Reply #4 on: January 16, 2011, 07:14:31 AM »
Quote
a thing that would clean up the path and remove duplicates or dead directories

Never could resist a challenge... this will tell you if a path exists; checking for dupes you'll have to do by Mark 1 eyeball at the moment...

Vista & W7 have a System path which everybody shares and individual user paths which are appended; XP & earlier has one (System) path variable. (It seems)

default XP path on a new install is

Code: [Select]
C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem
default W7 path on a new install is

Code: [Select]
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
ListPath.vbs; run with Cscript

Code: [Select]
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject( "WScript.Shell" )
' 2 passes - 1 system 2 this User
For pass = 1 To 2
If pass=1 Then
EnvType="system"
Else
EnvType="user"
End If
' Get path variable       
Set wshSystemEnv = wshShell.Environment( EnvType )
          MyPath = wshSystemEnv("PATH")
          If LCase(EnvType) = "system" Then
MyEnvType = "[System]"
  Else          
          MyEnvType = "[ User ]"
          End If
       ' Split PATH string on semicolons (i.e. list folders)   
       ' store in array
       PathArray = Split (MyPath, ";", -1, 1)
     FirstFolder = 0
      LastFolder = UBound(PathArray)
' Step thru array     
For j = FirstFolder To LastFolder
PathFolderName = PathArray(j)
' VBS does not expand env vars like %systemfolder%
' so make cmd do this
Set CmdExpandName  = wshShell.Exec("cmd /c echo " & PathFolderName)
ExpandedFolderName = CmdExpandName.StdOut.ReadLine
If fso.FolderExists(ExpandedFolderName) Then
        wscript.echo "[Folder exists: yes] "  & MyEnvtype & " " & ExpandedFolderName
    Else
wscript.echo "[Folder exists:  no] "  & MyEnvtype & " " & ExpandedFolderName
    End If
Next
Next

XP Professional 32 bit SP3

Code: [Select]
[Folder exists: yes] [System] C:\Program Files\Windows Resource Kits\Tools\
[Folder exists: yes] [System] C:\Perl\site\bin
[Folder exists: yes] [System] C:\Perl\bin
[Folder exists: yes] [System] C:\
[Folder exists: yes] [System] C:\WINDOWS
[Folder exists: yes] [System] C:\WINDOWS\system32
[Folder exists: yes] [System] C:\WINDOWS\System32\Wbem
[Folder exists: yes] [System] c:\batch
[Folder exists: yes] [System] C:\utils
[Folder exists: yes] [System] c:\program files\ruby\bin
[Folder exists: yes] [System] C:\Program Files\Windows Resource Kits\Tools
[Folder exists: yes] [System] c:\Program Files\Python
[Folder exists: yes] [System] C:\batch\vbs
[Folder exists: yes] [System] C:\Program Files\Common Files\DivX Shared\
[Folder exists: yes] [System] C:\Program Files\rksupport

W7 64 bit Professional

Code: [Select]
[Folder exists: yes] [System] C:\Program Files (x86)\ImageMagick-6.6.2-Q16
[Folder exists: yes] [System] C:\Ruby\bin
[Folder exists: yes] [System] C:\Program Files (x86)\Windows Resource Kits\Tools\
[Folder exists: yes] [System] C:\Windows\system32
[Folder exists: yes] [System] C:\Windows
[Folder exists: yes] [System] C:\Windows\System32\Wbem
[Folder exists: yes] [System] C:\Windows\System32\WindowsPowerShell\v1.0\
[Folder exists: yes] [System] c:\batch
[Folder exists: yes] [System] c:\utils
[Folder exists: yes] [System] c:\batch\vbs
[Folder exists: yes] [System] C:\Program Files\XviD MPEG-4 Video Codec 1.2.2 64-BIT
[Folder exists: yes] [System] C:\Program Files (x86)\Common Files\DivX Shared\
[Folder exists: yes] [System] C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
[Folder exists: yes] [System] C:\Program Files (x86)\QuickTime\QTSystem\
[Folder exists: yes] [ User ] C:\Program Files (x86)\TCL\bin
[Folder exists: yes] [ User ] C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\
[Folder exists: yes] [ User ] F:\gnuplot\binary

Salmon Trout

  • Guest
Re: Can I clean up by PATH. HP trashed it!
« Reply #5 on: January 16, 2011, 09:13:32 AM »
Sorry, I screwed up the indenting before (I pasted code between code /code tags without first converting tabs to spaces)

Code: [Select]
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = CreateObject( "WScript.Shell" )
' 2 passes - 1 system 2 this User
For pass = 1 To 2
        If pass = 1 Then
                EnvType = "system"
        Else
                EnvType = "user"
        End If
        ' Get path variable       
        Set wshSystemEnv = wshShell.Environment(EnvType)
                  MyPath = wshSystemEnv("PATH")
                  If LCase(EnvType) = "system" Then
                        MyEnvType = "[System]"
                  Else                         
                        MyEnvType = "[ User ]"
                  End If
               ' Split PATH string on semicolons (i.e. list folders)   
               ' store in array
               PathArray = Split (MyPath, ";", -1, 1)
             FirstFolder = 0
              LastFolder = UBound(PathArray)
        ' Step thru array     
        For j = FirstFolder To LastFolder
                PathFolderName = PathArray(j)
                ' VBS does not expand env vars like %systemfolder%
                ' so make cmd do this
                Set CmdExpandName  = wshShell.Exec("cmd /c echo " & PathFolderName)
                ExpandedFolderName = CmdExpandName.StdOut.ReadLine
                If fso.FolderExists(ExpandedFolderName) Then
                        wscript.echo "[Folder exists: yes] "  & MyEnvtype & " " & ExpandedFolderName
                Else
                        wscript.echo "[Folder exists:  no] "  & MyEnvtype & " " & ExpandedFolderName
                End If
        Next
Next

Fleexy



    Intermediate

  • OW NEXT TIME I SHOULD TURN IT OFF BEFORE SERVICING
  • Thanked: 2
    • Yes
    • Yes
  • Experience: Experienced
  • OS: Windows XP
Re: Can I clean up by PATH. HP trashed it!
« Reply #6 on: January 16, 2011, 12:26:39 PM »
The attached program (PathLock) will monitor for PATH changes and stop them.  You can set a path that it will enforce.  Currently, it can't check for dead directories.  This works in WinXP (I haven't tested in other OSes).  You may wish to put it in your startup.

[recovering disk space - old attachment deleted by admin]
I love .NET!

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Can I clean up by PATH. HP trashed it!
« Reply #7 on: January 16, 2011, 01:01:34 PM »
An application cannot be made to "monitor" for changes to environment variables, because they are inherited per-process and each application can have a different set. When you write an application for monitoring changes to a environment variable, you are really just monitoring wether that programs' copy of the variable changes.

For example- open two command prompts. Type Set path=C:\ in one of them. use the path command in the other. Note that the output is no different.
I was trying to dereference Null Pointers before it was cool.

Salmon Trout

  • Guest
Re: Can I clean up by PATH. HP trashed it!
« Reply #8 on: January 16, 2011, 01:33:20 PM »
An application cannot be made to "monitor" for changes to environment variables, because they are inherited per-process and each application can have a different set. When you write an application for monitoring changes to a environment variable, you are really just monitoring wether that programs' copy of the variable changes.

For example- open two command prompts. Type Set path=C:\ in one of them. use the path command in the other. Note that the output is no different.

I guess it monitors the values stored in the registry* in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path (I think that XP stores the whole PATH and W7 stores the system part of its PATH here) and maybe HKEY_CURRENT_USER\Environment\Path (W7 user path) although Fleexy says he has not tried it in other OSs than XP.

Personally I would not be inclined to download and run an app, that has registry access, from some guy in a forum.

* a hex view seems to bear this out, but I am no VB expert.



Although I am not so keen on this



Could be just to get updates I suppose






« Last Edit: January 16, 2011, 02:00:15 PM by Salmon Trout »

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Can I clean up by PATH. HP trashed it!
« Reply #9 on: January 16, 2011, 06:06:18 PM »
Could be just to get updates I suppose

I would imagine it's probably just a reference, maybe it's unique to 2010 or VB.NET because I got curious and checked some of my C# applications and none of them have anything like that inside them (perhaps I'm just more diligent with my references? :P


Regarding the application key; it actually doesn't work so well. I cannot remember the specific instance or why I needed it but I tried to monitor that key to do something similar (detect changes to a environment variable) and it didn't work at all; this is because that particular key only determines the (as you noted) System path; it will have no effect on the User's Path variable (which is to say, it will (I believe) change the path for applications run as the administrator (in Vista and 7), but those that aren't neither have access to that key nor have an environment block that contains values from that key... unless the "notification" program mirrors those values into the corresponding location in CURRENT_USER.

I think a more useful course of action might be for Geek to actually post his Path setting so we can see exactly what he is referring to. My %path% has 69 folders, and certainly could have a lot of folders removed from it; even those that do exist (I do quite like the idea of checking the path variable for non-existent folders).

Building a utility to "protect" the path seems pretty redundant, though. It would probably be more annoying in the long run, and it seems like overkill. If one is going to "protect" t he Path variable, why not any number of other various system variables?
I was trying to dereference Null Pointers before it was cool.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can I clean up by PATH. HP trashed it!
« Reply #10 on: January 16, 2011, 07:56:02 PM »
You two are amazing! I am oblown away with your knowledge.
Here is a copy of PATH from the Desktop, which is similar to the laptop.
Code: [Select]
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings>
C:\Documents and Settings>PATH
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn;C:\Program Files\Common Files\HP\Digital Imaging\bin;C:\Program Files\HP\Digital Imaging\bin\;C:\Program Files\HP\Digital Imaging\bin\Qt\Qt 4.3.3;;C:\Program Files\Smart Projects\IsoBuster

C:\Documents and Settings>

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Can I clean up by PATH. HP trashed it!
« Reply #11 on: January 16, 2011, 09:10:09 PM »
why can't you just remove some of the folders from it?

You can do so using the Control Panel->System, and I forget the specific tab (Hardware? Settings?) for XP, but there is an option to show environment variables, where you can edit the System and User variables, including the Path variables.
I was trying to dereference Null Pointers before it was cool.

Geek-9pm

    Topic Starter

    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Can I clean up by PATH. HP trashed it!
« Reply #12 on: January 16, 2011, 09:35:24 PM »
Yeah, I can do that.
MyComputer>Proerties>Advanced>Wvviromental Variables>Path>Edit
Thee I do set it this way:
Code: [Select]
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;D:\BINReboot and at the command prompt I get:

Code: [Select]
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings>path
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;D:\BIN;C:\Program Files\Common Files\Microsoft Shared\Windows Live

C:\Documents and Settings>
Got rid oHP and all the other stuff I never use. Except the Windows Live just walks on in!

But it now works OK and I got my D:\BIN where I want it. Which was the reason I started to look at the PATH in the first place. Why can others have neat short path names? It would make things easier

Thank you all !


Ecurb

  • Guest
Re: Can I clean up by PATH. HP trashed it!
« Reply #13 on: April 02, 2015, 03:05:07 PM »
Salmon Trout,

Great little utility.  I used it to clean up my Byzantine path.  To help get rid of the duplicates I just piped the output into sort and got all the dups grouped with each other.

Thanks for sharing, still going strong after all these years.

Bruce