[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Accessing the Registry file



Ed Kelly wrote:

> Does anyone know if an SQR program can access the Windows Registry file?
> I am running SQR v4.0 on an NT 4 platform.  I am assuming that the
> answer is no (at least not directly); however, I have been unable to
> find a definitive answer in the SQR User's Guide or Language Reference.

A few months ago I needed to prompt for input in a DOS .bat file. One of my
coworkers found http://www.calweb.com/~webspace/batch which solved my problem
.... and then some! BTW, I am not a strong proponent of DOS based solution, nor
do I even know who "calweb.com" is, but I do appreciate them putting their info
on the web.

I do not know if "direct" access from SQR will work, but you may be able to
create a "DOS" .bat file which puts the required registry entries into a
temporary file. SQR could run the .bat file, then read the registry entries
from the temporary file. See
http://www.calweb.com/~webspace/batch/samples/username.txt for details on how
to get the current Windows or network username from the registry. I tried the
batch file on my Windows 95 machine and it worked! NT may work, too, but I do
not have one available to check. In case your internet access is "sporadic", I
am including the sample batch code (I believe the second line dumps the entire
branch of the registry into reg.txt and the rest extracts the "current user"
value and puts it into an environment variable):

@echo off
start /w regedit /e reg.txt HKEY_LOCAL_MACHINE\System\CurrentControlSet\control

type reg.txt | find "Current User" > "Current#User.bat"
echo set CurrentUser=%%1>"Current User.bat"
call "Current#User.bat"
del "Current?User.bat" > nul
del reg.txt > nul
echo %CurrentUser%
exit

Good luck!

--
Steven Calvert
calvert@uleth.ca
University of Lethbridge
(403)329-2071