This line needs some looking at:
programs=REG_SZ C:\Documents and Settings\USER\Start
Menu\Programs\Administrative Tools
Are you keen to make it a batch file only utility? There are some tools
around that return all sorts of data - SIW is one that has command line
switches.
System Information for Windows 2010 (build 0714a) Freeware Version
--
Regards,
Mic
http://usetools.net/dvl/cmd/shellget.cmd
shellget.cmd is highly universal, fast and smart script-tool written
on Windows NT operating system built-in command interpreter which is
console shell (text terminal).
this code was tested thousents times on plenty of hardware
configurations range: P2/K6-2 120mb ram - P4/Xeon 4gb ram; various
form factors like pc tower/desktop, laptop, notebook, netbook, eeepc,
etc.
its made for still the most wide-spread in the world os NT 5.1 i.e.
Windows XP SP2-SP3 and can be easily adopted for the later products of
wellknown company.
this script is one piece of integrated installation, configuration and
administration toolset (i can tell more than everything about that in
detail but not this time). but it is independent, doesnt require
anything besides it self and built-in system components, cause i
specially cut it as separate module for doing rather useful thing
which is absent in cmd (maybe it sounds stupid in some extance but
there in cmd is no %localappdata% and %desktop% built-in by default,
isnt it?). it can be used for variaty of possible tasks like
installation, backup, clean-up, fix-up, etc. by the way i implemented
only the first part of features which i planned for getshell.cmd
a lot of practical experiments showed that cmd is excellent solution
for Windows service, installation, administration, system control,
etc. it runs very FAST and SAFE, very lightwait source which is ready
to run and can be modified on the go.
naturally additional tools is the second power of enviroment in case
it is configured properly. thus such multifunctional tools as NirCmd
or Comandiux and others are great for many tasks and we use them very
often in scripts. this concrete procedure of getting shell enviroment
was checked by many versions of tools combinations and finally pure
cmd is winner. but if you can show better alternative we will get the
new knoledge together. anyway.
by the way SIW is my old friend, we collect system hardware info
together via cmd script packed there http://usetools.net/softpacks/fastpack
SIW is too large utility for such task and it is not basic function,
it just can use win api, but cmd should catch faster from registry.
one more serious problem is that SIW can hang (on my practice is took
place several times on some cheap SiS mobo) and far important tasks it
is total failure. sorry, great anecdote! =)
> by the way SIW is my old friend
actually SIW was my old friend but i excluded it from package cause of
bugs, the latest was that SIW couldnt start in one directory with
pcidevs.txt and other similar hwid database files. they make it mad,
thats enadequate. (and it has limited export features, shows less
useful software tab by default that couldnt be changed, it even doesnt
allow to copy-paste info about some unknown devices and boards without
problems, offers payd version) but SIV has the real power of logging
various information about system and it uses pcidevs.txt database like
other full-featured gui and console tools.
This is a little more robust. It uses GNUsed
@echo off
:: CURRENT USER
set
hkcushell=hkcu\software\microsoft\windows\currentversion\explorer\shell
folders
for /f "skip=3 tokens=1,* delims=|" %%a in (
'reg query "%hkcushell%" /s ^|sed "s/\x09REG_SZ\x09/|/"'
) do set "%%a=%%b"
set
pause
--
Regards,
Mic
thank you, its very interesting code. i tested it and got such screen
output: http://i.imgur.com/yL1Ao.png
so i think that these are all currently existing enviroment variables
and their values i.e. system and users enviroment output.
i think its extremely useful cause i usually use special separate cmd
tool for this task.
did i miss smth?
and its rather sad but i havent any experience with sed.
would you mind to explain a little bit this magic for cycle with
sed?.. (if it is not very difficult for you)
@echo off
:: CURRENT USER
set
hkcushell=hkcu\software\microsoft\windows\currentversion\explorer\shell
folders
for /f "skip=3 tokens=1,* delims=|" %%a in (
'reg query "%hkcushell%" /s ^|sed "s/\x09REG_SZ\x09/|/"'
) do set "zzz %%a=%%b"
set zzz
pause
The above addition will show only the variables defined, filtering for "zzz"
> thank you, its very interesting code. i tested it and got such screen
> output: http://i.imgur.com/yL1Ao.png
> so i think that these are all currently existing enviroment variables
> and their values i.e. system and users enviroment output.
Yes, it's the current environment. See above for a method to only list
the variables that are set by the code.
> i think its extremely useful cause i usually use special separate cmd
> tool for this task.
> did i miss smth?
> and its rather sad but i havent any experience with sed.
> would you mind to explain a little bit this magic for cycle with
> sed?.. (if it is not very difficult for you)
sed in the case above uses the "s/find/replace/" syntax and it replaces
TABREG_SZTAB with a pipe character | where tab is ascii character HEX 09
and is represented by \x09 in gnused.
The for in do then skips the top three lines of the registry code and
splits the rest of the lines into the "category name" and "the path"
(using the pipe character) into %%a and %%b
--
Regards,
Mic
thank you again, i will update the script with adding of your code as
soon as possible. =)
:: usetools.net command shell script
:: allows to get shell folders values to vars, write shell folders
values and all enviroment vars to ini file
::
@echo off
::
:: CURRENT USER
set hkcushell=hkcu\software\microsoft\windows\currentversion\explorer
\shell folders
set hklmshell=hklm\software\microsoft\windows\currentversion\explorer
\shell folders
::set hklmshell=hklm\software\microsoft\windows\currentversion\explorer
\user shell folders
for /f "tokens=3*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common AppData"') do set "allappdata=%%b"
for /f "tokens=3*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Desktop"') do set "alldesktop=%%b"
for /f "tokens=4*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Start Menu"') do set "allstartmenu=%%b"
for /f "tokens=3*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Programs"') do set "allprograms=%%b"
for /f "tokens=3*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Startup"') do set "allstartup=%%b"
for /f "tokens=4*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Administrative Tools"') do set "alladmintools=%%b"
:: next values need to be tested on different systems
::for /f "tokens=3*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Documents"') do set "alldocs=%%b"
::for /f "tokens=3*" %%a in ('reg query "%hklmshell%" /s ^|find /i
"Common Favorites"') do set "allfavorites=%%b"
::
:: MAKE INI FILE
:makeini
set shellgetini=%userprofile%\shellget.ini
echo ; %~nx0 --- %date% %time% --- >"%shellgetini%"
echo [shellget]>>"%shellgetini%"
for /f "skip=3 tokens=1,* delims=|" %%a in (
'reg query "%hkcushell%" /s ^|sed "s/\x09REG_SZ\x09/|/"'
) do set "%%a=%%b"
set>>"%shellgetini%"
::
::echo [shellget]>>"%shellgetini%"
::echo localappdata=%localappdata%>>"%shellgetini%"
::echo desktop=%desktop%>>"%shellgetini%"
::echo mydocs=%mydocs%>>"%shellgetini%"
::echo startmenu=%startmenu%>>"%shellgetini%"
::echo programs=%programs%>>"%shellgetini%"
::echo startup=%startup%>>"%shellgetini%"
::echo sendto=%sendto%>>"%shellgetini%"
::echo qlaunch=%qlaunch%>>"%shellgetini%"
::echo docs=%docs%>>"%shellgetini%"
::echo defaultuser=%defaultuser%>>"%shellgetini%"
::echo defaultappdata=%defaultappdata%>>"%shellgetini%"
::echo defaultlocalappdata=%defaultlocalappdata%>>"%shellgetini%"
::echo defaultsendto=%defaultsendto%>>"%shellgetini%"
::echo defaultqlaunch=%defaultqlaunch%>>"%shellgetini%"
::echo allappdata=%allappdata%>>"%shellgetini%"
::echo alldesktop=%alldesktop%>>"%shellgetini%"
::echo allstartmenu=%allstartmenu%>>"%shellgetini%"
::echo allprograms=%allprograms%>>"%shellgetini%"
::echo allstartup=%allstartup%>>"%shellgetini%"
::echo alladmintools=%alladmintools%>>"%shellgetini%"
::
:end
:: http://usetools.net/dvl/cmd/shellget.cmd
:: http://groups.google.com/group/alt.msdos.batch.nt/browse_thread/thread/f0daad06d9b89ddb
::