On Sat, 14 Mar 2009 00:16:40 -0500, dcantor <> wrote:
|Does anyone have a way to convert ASCII strings to Unicode or vice versa within TCC?
|
|Reason, probably use: Given a scheduled task running TCC, I'd like to find the name of the scheduled task which started the process. The commands within the scheduled task .JOB files are in Unicode, but I'd like to use FFIND to locate the .JOB file containing the name of the running batch file.
Here's a little tidbit (readjob.btm, far below); it could be much simpler but I
was having so much fun that I got carried away. First, it's output:
v:\> readjob.btm IPcheck.job
ExeName: D:\4NT\4nt.exe
Parameters: /c d:\uty\ipcheck.bat
Directory: D:\4NT
UserName: vefatica
REM READJOB.BTM
if not exist %1 .or. "%@ext[%1]" NE "JOB" quit
setlocal
set /a nBytesNeeded=%@filesize[%1] - 72
set hMem=%@balloc[%nBytesNeeded]
set hFile=%@fileopen[%1,r,b]
set NulCount=0
unset /q String
set nBytesRead=%@bread[%hMem,0,%hFile,72,%nBytesNeeded]
do i=0 to %nBytesRead by 2
set nUnicode=%@bpeek[%hMem,%i,2]
iff %nUnicode == 0 then
set /a NulCount+=1
switch %NulCount
case 1
echos ExeName
case 2
echos Parameters
case 3
echos Directory
case 4
echos UserName
endswitch
echo :^t%String
unset /q String
if %NulCount GE 4 leave
elseiff %nUnicode GT 32 then
set String=%[String]%@char[%nUnicode]
elseiff %nUnicode == 32 then
set String=%[String]` `
endiff
enddo
set hFile=%@fileclose[%hFile]
set hMem=%@bfree[%hMem]
endlocal
I'm no expert on the format of JOB files but this tests OK with the few examples
I have hanging around.
--
- Vince