Unfortunately, Win98 and WinNT/Win2k use radically different methods (i.e., API calls) to access the process table. So what you need is a platform aware utility that determines the platform and makes the appropriate API calls , then returns the list to the command line so you can grab it with a script.
Here's a utility to do just that - it's called PrcView. It looks like it returns quite a bit of information, but a little regular expression matching should allow you to extract what you need. Note that PSAPI.DLL is required on NT (that's the DLL that provides the API to access the process table) - it's not always present so you may need to install it.