Page 1 of 1 1
Topic Options
#13570 - 2001-10-26 09:54 AM EXIST Bug?
Anonymous
Unregistered


Hi there,

can anyone please tell me what is wrong here:

code:

$ProfilesDir=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","ProfilesDirectory")
$DUProfFile=$ProfilesDir + "\Default User\SendTo\Notepad.lnk"
IF EXIST ( "$DUProfFile" )
"+"
ELSE
"c"
copy "$DataSource\NotePadLinks\NTNotPad.lnk" "$DUProfFile"
ENDIF


In NT4
1. line: Reading Profiles Path from Registry (it returns: "%SYSTEMROOT%\Profiles")
2. line: Add specific filename
3. check if file exists
if so write a "+" if not copy

My Problem is that EXIST ("$DUProfFile") says file not exist although the value of the var is "%SYSTEMROOT%\Profiles\Default User\SendTo\Notepad.lnk" and the specified files is existing. And it does not copy that one as well.

Same thing on
$ProfilesDir + "\Administrator\SendTo\Notepad.lnk"

Thanks for help

Fabian

Top
#13571 - 2001-10-26 05:08 PM Re: EXIST Bug?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Fabian,

definitely no bug in exist() !

3 things :

I have an NT4 SP 6a Box here and there is no Registry Value "%SystemRoot%\Profiles", except some entries starting with that in HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\ and some below the Key in question, but within subkeys named after User SID's !!!

Adding a NotePad.lnk under the path in question and setting $DUProfFile = "%SystemRoot%\Profiles\Default User\SendTo\Notepad.lnk" resulted in "+" .. so exist() is working perfect !

In your sample code you copy NTNotPad.lnk if Notepad.lnk doesn't exist in the path you specify ...

Jochen

_________________________



Top
#13572 - 2001-10-26 08:11 PM Re: EXIST Bug?
Anonymous
Unregistered


Jochen,

3 things in return

1) There is a key in the registry called ProfilesDirectory under HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfilesList. (Make sure you are using Windws NT subkey.
Of course there are subkeys including SIDs, this have to be. But this is the best way to find out where the local profiles are stored. The ProfilesList entry is for Default User and All Users Profile important.
And all new users logging to that machine will get a local profile in that directory. You can change that and copy all profiles to another local hard drive. Key available on NT4, 2000 and I think XP as well.

2) EXIST is working in the way you are using this. Setting a var with these values.
It is working when you read a complete path without enviroment vars from the registry.
But it is not working in the way I am using it: combining a registry key including a enviroment var and a string.
The first two ways result in "+" the third in "c".
a) %SystemRoot%\Profiles\...
b) C:\WinNT\Profiles\... (from a key created)
c) %SystemRoot%\Profiles\... (not working if in key)

3) I am trying to copy one link into another because in the source folder is another file for 9x 9xnotpad.lnk. Usual way for copying and renaming within one step.

Please try it by yourself. Create a key in the Registry. Like HKCU\Software\Test="%SystemRoot%\Notepad.exe". Read it with Kix and try to find that file.

Fabian

[ 26 October 2001: Message edited by: Fabian Koehlmann ]

Top
#13573 - 2001-10-26 08:40 PM Re: EXIST Bug?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Fabian,

correct .. I was on the worng path !
It failed with the SystemRoot variable in the key ! Looking for a workaround and get back to you on Monday (Have to go now =)

was slightly irritated because of the value missing in MY registry

J.

_________________________



Top
#13574 - 2001-10-26 09:05 PM Re: EXIST Bug?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Fabian,

here's a first try ... weird but working :

code:

break on

$ProfilesDir=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList","ProfilesDirectory")
$DUProfFile= "\Default User\SendTo\Notepad.lnk"

$ = execute('if exist("'+$ProfilesDir+'$$DUProfFile") "+" ? else "c" ? endif')
get $


J.

_________________________



Top
#13575 - 2001-10-26 09:46 PM Re: EXIST Bug?
Anonymous
Unregistered


J,

thanks, but this won't resolve all other problems which appear.

I played with that "bug" and it seems that this is not just an EXIST bug. Every funktion I tried failed by resolving the file name. I got @ERROR=3 (path not found) all the time.

I tried GetFileSize, GetFileAttr, GetFileTime, Open, Copy, Del, Dir (when entering a directory). Close and Readline make no sense.
And other enviroment vars like %TEMP%, %TMP%, %WINDIR%, %SYSTEMDRIVE%.

So, it looks like a general bug to me.

Maybe I should start a new topic "KIX REGISTRY-FILE NAME RESOLVING BUG...

Fabian

[ 26 October 2001: Message edited by: Fabian Koehlmann ]

Top
#13576 - 2001-10-26 10:55 PM Re: EXIST Bug?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Fabian,
I think there are other issues at play here. I don't believe there is any "bug". In what circumstance does this manifest itself; during the logon or after? Perhaps it's a permissions issue.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#13577 - 2001-10-26 11:21 PM Re: EXIST Bug?
Anonymous
Unregistered


Les,

this happens everytime. During or after login, with or without admin rights, with kix 3.42, 3.63, 2001 rc3. On W2k Sp1, Sp2; NT4 Sp5, Sp6a.
I asked Jochen to try at his machine, he encountered the same problems.
It transfers the value to the var correctly but when I am using it in the script it seems that kix can not resolve the %var% part. Have a look at the examples and give yourself a try.

Fabian

Top
#13578 - 2001-10-27 12:31 AM Re: EXIST Bug?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You're missing one step. the answer lies in

ExpandEnvironmentVars()

Add these two line to J's code:

? "$$Profilesdir = " + $Profilesdir
? ExpandEnvironmentVars( $Profilesdir )

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#13579 - 2001-10-27 01:31 AM Re: EXIST Bug?
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
This code seems to work. Thanks Les.

code:
$Profilesdir = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory")
$RealValue = ExpandEnvironmentVars($Profilesdir)
? $Profilesdir
$DUProfFile = $RealValue + "\Default User\SendTo\Notepad.lnk"
? $DUProfFile
IF EXIST ("$DUProfFile")
? "Found Notepad"
ELSE
? "Did Not find Notepad"
copy "C:\TEMP\NTNotPad.lnk" "$DUProfFile"
ENDIF


Top
#13580 - 2001-10-27 01:40 AM Re: EXIST Bug?
Anonymous
Unregistered


Big thanks Les,

I know why I could not solve that problem by myself. The funktion ExpandEnvironmentVars is missing in the Kixtart.chm for 2001. It is in there but not listet in Function Reference which I was using. I was searching for it and it found it.
In Kixhelp.chm for it is included.

Again, thanks Les.

Top
#13581 - 2001-10-27 05:18 AM Re: EXIST Bug?
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Indeed all kind of additional documentation exist, but sometimes a little
conversion problem was introduced. We also missing the ExpandEnvironmentVars function
in the index of one of them.
We are only the chm for a fast and easy way of searching for the correct
parameters, formats and results of commands and functions.

Our primary source is always the original documentation of Ruud van Velsen,
which is distributed by kixtart releases.


Currently we are reviewing the latest documentation version of kixtart RC3 release.
So we will take also look at the chm version of scriptlogic. It is
the one compliant with this release.
greetings.

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#13582 - 2001-10-27 05:58 AM Re: EXIST Bug?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
My "bible" is ScriptLogic's CHM documentation. The KiX 4 version especially. The older 3.6x version used curly quotes in some examples that, when cut and pasted, don't work. Also several errors in the old version.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#13583 - 2001-10-27 08:23 PM Re: EXIST Bug?
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Thanx Les !!!

The same problem here ... using strictly the compiled html version from Scriptlogic ->
I think I saw that ExpandEnvironmentVars() function at least once in my KiX career but never used it ...
I use two versions of the .chm's : 3.63 and the latest 2001 one ...

In 3.63 version it's in the listing when you click on the chapter functions!
In the 2001 one it's in the keyword index and in the function listing ...
But both versions do miss it when expanding the functions chapter ...

The german jury gives this :

Hmm .. ok, but it was quite funny and interesting to do an execute struggle once more ! Saved my code several times yet ...

regards

Jochen

_________________________



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 774 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.065 seconds in which 0.026 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