#13570 - 2001-10-26 09:54 AM
EXIST Bug?
|
Anonymous
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
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
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
|
|
|
|
#13575 - 2001-10-26 09:46 PM
Re: EXIST Bug?
|
Anonymous
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
|
|
|
|
#13577 - 2001-10-26 11:21 PM
Re: EXIST Bug?
|
Anonymous
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
|
|
|
|
#13580 - 2001-10-27 01:40 AM
Re: EXIST Bug?
|
Anonymous
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1179 anonymous users online.
|
|
|