WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System INI and INI File Topics

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IniReadPVt always Returns Default

 Keywords: IniReadPVt Returns Default Value Blank String

Question:

I am trying to read the url from the internet shortcuts (.url files) listed in the users favorites subdirectory. However I am always getting back a blank string. I have confirmed there are .url files located in this directory:
sFavoritesPath = RegQueryStr(@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders[Favorites]")
DirChange (sFavoritesPath)
sFiles = FileItemize("*.url")
sFileCount = ItemCount(sFiles, @TAB)
for i = 1 to sFileCount
   sFileToRead = ItemExtract(i, sFiles, @TAB)
   sURL = IniReadPvt("InternetShortcut", "URL", "", sFileToRead)
   Pause(sFileToRead,sURL)
next
Message("", "DONE")

Answer:

On close inspection of the IniReadPvt statement, I see you are not specifying a full PATH to your INI file. The documentation for IniReadPvt states: Notes: Path information must be specified, if the INI file is not in the Windows directory. If there is no path information provided, then the INI file is assumed to be in the Windows directory (as shown by DirWindows(0) )

Here is some modified code:

 
sFavoritesPath = RegQueryStr(@REGCURRENT, "Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders[Favorites]")
DirChange (sFavoritesPath)
sFiles = FileItemize("*.url")
sFileCount = ItemCount(sFiles, @TAB)
for i = 1 to sFileCount
   sFileToRead = ItemExtract(i, sFiles, @TAB)
   sURL = IniReadPvt("InternetShortcut", "URL", "", sFavoritesPath:'\':sFileToRead) ;;;;;;INCLUDE FULL FILE PATH TO INI
   Pause(sFileToRead,sURL)
next
Message("", "DONE")

Article ID:   W18292
Filename:   IniReadPVt always Returns Default.txt
File Created: 2013:08:12:12:28:48
Last Updated: 2013:08:12:12:28:48