This content has been marked as final. Show 3 replies
most times i'm searching the file on the filesystem, create an INI-Based-File and work with the section of the INI-File.
To search the File and get the Path to it, i use a normal Batch-File like this:
FOR /F "Tokens=1" %%i in ('dir /b /s %_file2check%') do (
The Parameters are given by the NetInstll Script wich is calling the Batch-File.
RunAs('.\extern$\check_folder.cmd %_server_name% %_file2check% %_check_folder_log%')
To read and parse an string from the registy i would also be interessted in.
Finally i got to excuse my bad english, hope you understand what i mean.
greetz from germany
i know its kinda late to answer to this thread, but better late than never
1) do retrieve the path only from a string, one can use the advanced features of the shell's "SET" command.
in a batchfile a construction like:
will result in %PSTPATH% containing the Path to the file %j, so if
%j is "c:\program Files\data\text.doc" ->%PSTPATH% will be "c:\program Files\data"
2) to retrieve a path from the registy i use a rather sophisticated piece of batch coding. The trick is to parse the output of "reg.exe" on the fly and process the results.
i'll post an example.
Lets say we want to find out where Adobe Photoshop has installed its Gamma Loader.
That information is contained in the registry at
"HKLM\Software\Adobe\Adobe Gamma" in a Key called "Location"
It looks like this:
Windows Registry Editor Version 5.00
"Location"="C:\\Programme\\Gemeinsame Dateien\\Adobe\\Calibration\\Adobe Gamma.cpl"
The Batch Script for getting that Value and dividing it in "Path" and "Filename" would be:
:: Example for retrieveing a files name and path from a registryvalue for further use within NetInstall
:: Result will look like this:
:: These Values can be read from a NetInstall script using ReadINI and processed easily.
:: %1 Name of Ini-Files
:: %2 Name of Temp-Directory that contains "reg.exe".
:: - reg.exe from Resource-Kit must be in %TEMPDIR%.
:: (Will be copied there by calling NI-script)
:: - Commandline Extensions for NT must be active (usually are)
:: (c) 2006 Martin Appel enteo Software GmbH
:: Create INI-File
:: Get Path and File that is contained in the value of keyword "Location", and call subroutine :PRINTIT with these values in Variables PNAME and PPATH
for /f "tokens=3" %%j in ('%TEMPDIR%\reg query "HKEY_CURRENT_USER\Software\Adobe\Adobe Gamma\Location"') do (
:: Add result to INI-File
echo PNAME=%PNAME% >>%INIFILE%
echo PPATH=%PPATH% >>%INIFILE%
This simple vbScript will get you the result you need.
The path is hardcoded, but you can use RegRead to grab it from the registry as well.
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheParent = fso.GetParentFolderName("C:\PROGRA~1\folder1\folder2\UNINST~1.EXE")