1.

Solve : batch file not working in XP?

Answer»

Can someone tell me why this does not work on XP.

@echo off
start /w regedit /e files.txt HKEY_LOCAL_MACHINE\System\CurrentControlSet\control
type files.txt | find "CURRENT User" > "Current#User.bat"
echo set CurrentUser=%%1>"Current User.bat"
call "Current#User.bat"
del "Current?User.bat" > nul
echo. Hello %CurrentUser% > files.txt
echo. WELL, what do you think? >> files.txt
rem check to see dir for tasks in xp
dir %Windir%\tasks /a >>> files.txt
echo. ****** >>>> files.txt
echo. Password List Below >>>>> files.txt
dir %Windir%\*.pwl >>>>>> files.txt
notepad files.txt
pause
cls
EXITecho set CurrentUser=%%1>"Current User.bat"

To get the first argument to a batchfile it is %1 not %%1
echo set CurrentUser=%1>"Current User.bat"

I don't really understand your batchfile.

uliokay this first section is to export a copy of the current user from the the registery key

@echo off
start /w regedit /e files.txt HKEY_LOCAL_MACHINE\System\CurrentControlSet\control
type files.txt | find "Current User" > "Current#User.bat"
echo set CurrentUser=%%1>"Current User.bat"
call "Current#User.bat"
del "Current?User.bat" > nul
----------------------------------------------------------------------------
this portion prints hello JOE BLOW (username) in the notepad file called files.txt
it also prints Well, what do you think.

echo. Hello %CurrentUser% > files.txt
echo. Well, what do you think? >> files.txt
----------------------------------------------------------------------------
this rem portion is just for my own info, I do not know for sure if C:\windows\tasks is LOCATED there for xp or not. If it is it will export a copy of any tasks waiting to be performed to the files.txt

rem check to see dir for tasks in xp


dir %Windir%\tasks /a >>> files.txt
-----------------------------------------------------------------------------

this will print a **** line to files.txt and the word Password List Below

echo. ****** >>>> files.txt
echo. Password List Below >>>>> files.txt
dir %Windir%\*.pwl >>>>>> files.txt
-----------------------------------------------------------------------------

All of it is then printed to files.txt in notepad and placed on the desktop.

notepad files.txt
----------------------------------------------------------------------------

and of course pause, cls, and exit.

pause
cls
EXIT

When I run the bat on my computer here is what I get.

Hello "Joe"
Well, what do you think?

Volume in drive C has no label
Volume Serial Number is 3031-1400
Directory of C:\WINDOWS\Tasks

. <DIR> 08-17-05 12:59p .
.. <DIR> 08-17-05 12:59p ..
SA DAT 6 10-27-05 6:48p SA.DAT
TUNE-U~1 JOB 502 05-11-98 8:01p Tune-up Application Start.job
DESKTOP INI 65 08-17-05 5:01p desktop.ini
3 file(s) 573 bytes
2 dir(s) 3,659.48 MB free
******
Password List Below

Volume in drive C has no label
Volume Serial Number is 3031-1400
Directory of C:\WINDOWS

Joe PWL 726 01-18-06 11:24a JOE.PWL
1 file(s) 726 bytes
0 dir(s) 3,659.48 MB free


For some reason I can not get it to work in WIN XP I run WIN 98
Oh by the way, if you use echo set CurrentUser=%1>"Current User.bat" it will not print the currentuser name. You must use %%1
for /f %%a in ('type files.txt ^| find "Current User"') set CurrentUser=%%a

echo %CurrentUser% >files.txt
echo Well..... >>files.txt
-----------------------------------------------

searches for the current user in the files.txt and writes it in a new files.txt file.
(If you just need the actual username you can also use the built in variable %USERNAME%)

This won´t work Win98, only in NT,W2k,Xp.

If you have the command tlist on your system, you can use this to list the running processes.

hope this helps
uli


Okay I will give it a SHOT and get back to you with the results.....Thanks ~ DwightWell, what happened was it gave me a ton of hkey listings. I do not know if that is what you intended or not.Oh no. I just wanted to find one current user. The loop finds every entry. Sorry.
I didn't consider how many entries the registry have.

uli



Discussion

No Comment Found