Page 1 of 1 1
Topic Options
#129543 - 2004-11-15 06:49 PM Kixtart Help
Liquid22 Offline
Fresh Scripter

Registered: 2004-11-11
Posts: 13
Hello,
I'm trying to write a script that will write bits of information to an INI file. I know how to gather basic info but what I really want to know is what drive mappings the PC has remembered. I can't figure out how to write the values of HKEY_CURRENT_USER\Network\ to an INI file and for each key it finds under "Network" I'd like to know what path is defined in RemotePath. Can someone help me with this?

Thanks in advance.

Top
#129544 - 2004-11-15 07:08 PM Re: Kixtart Help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well here is an example of how to manipulate the .INI file.

Replace a value in an INI file

As for the other items, please let us know what version of KiXtart you're using and what OS versions you need to support.

Top
#129545 - 2004-11-15 08:04 PM Re: Kixtart Help
Liquid22 Offline
Fresh Scripter

Registered: 2004-11-11
Posts: 13
I'm using 4.22 and would like it to support Win 9x as well as Win2K / XP.

I know how to manipulate the INI file but I'm running into a problem with HKEY_CURRENT_USER\Network key which is where remembered network connects are stored. After "Network" there is another subkey that is represented by a drive letter, for example HKEY_CURRENT_USER\Network\Z would mean I have a Z drive mapped and inside of the Z subkey is a DWORD value "RemotePath" that tells me what path Z is mapped to. My problem is I don't know how to enumerate all those keys and subkeys and RemotePath values into an INI file.

Top
#129546 - 2004-11-15 09:10 PM Re: Kixtart Help
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well if you already know how to manipulate the .INI file then here is some code to get the information you're looking for.

Code:
Break On
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')

Dim $Drives,$Drive,$RemotePath
$Drives=arrayenumkey('HKCU\Network')

For Each $Drive In $Drives
If $Drive
$RemotePath=ReadValue('HKCU\Network\'+$Drive,'RemotePath')
? $Drive + ' is mapped to: ' + $RemotePath
EndIf
Next

Function arrayenumkey($regsubkey)
dim $retcode, $subkeycounter, $currentsubkey, $subkeyarray
if not keyexist($regsubkey)
exit 87
endif
$subkeycounter=0
do
$currentsubkey=enumkey($regsubkey,$subkeycounter)
if not @ERROR
redim preserve $subkeyarray[$subkeycounter]
$subkeyarray[$subkeycounter]=$currentsubkey
$subkeycounter=$subkeycounter+1
endif
until @ERROR
$arrayenumkey=$subkeyarray
exit 0
EndFunction



Let us know how it works out, or if you need further assistance. As for the Windows 9x support, I don't have any Windows 9x to test on but if you allow profiles on your Windows 9x then this will be hard to do as this is not available during logon.

Top
#129547 - 2004-11-15 09:19 PM Re: Kixtart Help
Liquid22 Offline
Fresh Scripter

Registered: 2004-11-11
Posts: 13
This is perfect - Thanks.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.052 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org