[V8i SS2 VBS] Installation folder issue

Hi Folks, I am executig code to test for the version of install external to MicroStation using VBS (company is not yet commissioned for PowerShell) on Win 7 and the following test fails to find the folder?

If InStr(1, subFolder, "08.11.07.443", vbTextCompare) > 0 Then

The folder in question is 'C:\Documents and Settings\All Users\Application Data\Bentley\Microstation'

The subfolders being tested recursively are '8.11' and '08.11.07.443'. The test does work if I remove the '8.11' folder!

Any ideas?

Parents
  • Unknown said:
    The subfolders being tested recursively are '8.11' and '08.11.07.443'. The test does work if I remove the '8.11' folder

    What sub-folders exist in the C:\Documents and Settings\All Users\Application Data\Bentley\Microstation directory?  Do both \8.11 and \8.11.07.443 exist, or just one of those?  Show us more code where you search for those folders.

    Hint: you might do better to post your question to a site that deals with VB script.

    Windows Registry

    Bear in mind that, with differing versions of Windows and MicroStation, those folders will also differ. A more reliable approach is to query the Windows Registry to determine where MicroStation and its data files are installed.

    You can query the Registry using VB Script. Here are some related links …

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • 1. Both  \8.11 and \08.11.07.443 exist

    2. I have posted the same question to MSDN

    3. I am testing for different OS. Unfortunately this is an addendum to existing scripts during a several month process of changing from WinXP to Win7. PowerShell is not yet approved for use. I have been reluctant to check the registry only because it is new to me and I had hoped to accomplish my requirement in the shortest timeframe.

    I've just been stumped as to why the Instr has an issue with multiple folders beginning with '8' and/or with '08'. I may have to try the registry if I can't get this working...

  • Unknown said:
    I had hoped to accomplish my requirement in the shortest timeframe

    Well, we all hope that.  Then we bump into something big and immovable.

    Unknown said:
    I've just been stumped as to why the Instr has an issue with multiple folders

    We still can't see your code, so it's hard to comment further.  How are you obtaining the list of sub-folders?

     
    Regards, Jon Summers
    LA Solutions

  • Hi cweber,

    of course instr(1,subfolder,'8.11',..) returns a value greater than 0 for '08.11.07.443'.

    It returns 2.

    You have to check if Instr() returns 1 which is only the case if the string starts with the sub-string you test.

    Read the Help for Instr to be sure about the function.

  • Function GetMicroStationVersion()

     Const USTN_APP_VERSION_SS2 = "V8i_SS2"

     Const USTN_APP_VERSION_SS3 = "V8i_SS3"

     Const USTN_APP_VERSION_SS3U1 = "V8i_SS3_Update_1"

     Const USTN_APP_VERSION_SS3U2 = "V8i_SS3_Update_2"

     Const UKNOWN_VERSION = "UKNOWN_VERSION"

     Const WinDataXP = "C:\Documents and Settings\All Users\Application Data\Bentley\MicroStation\"

     Const WinProgXP = "C:\Program Files\Bentley\MicroStation\"

     Const WinData7 = "C:\ProgramData\Bentley\MicroStation\"

     Const WinProg7 = "C:\Program Files (x86)\Bentley\MicroStation\"

     Dim PathProg

     Dim PathData

     Dim Osys  

     ' Determine Operating System

     If oFileSys.FolderExists(WinProg7) And oFileSys.FolderExists(WinData7) Then

         Osys = "Windows 7"

         PathProg = WinProg7

         PathData = WinData7

     ElseIf oFileSys.FolderExists(WinProgXP) AND oFileSys.FolderExists(WinDataXP) Then

         Osys = "Windows XP"

         PathProg = WinProgXP

         PathData = WinDataXP

     Else

        Wscript.Echo "Error: Valid Windows OS not found!"

     End If

     'Wscript.Echo Osys

     ' Get MicroStation version from child folders

     Dim GetPP

     Dim GetPD

     GetPP=TraverseFolders(oFileSys.GetFolder(PathProg))

     Wscript.Echo GetPP

     GetPD=TraverseFolders(oFileSys.GetFolder(PathData))

     Wscript.Echo GetPD

     If GetPP = GetPD Then

    GetMicroStationVersion = GetPP

     Else

    Wscript.Echo "Error: Valid installation not found!"

     End If

    End Function

    ' ---------------------------------------------------------------------

    ' Recursion - create a self-referencing function

    ' ---------------------------------------------------------------------

    Function TraverseFolders(folder)

     TraverseFolders = vbNullString

     Dim subFolder

     For Each subFolder In folder.SubFolders

    ' Recurse on all the sub-folders

    TraverseFolders subFolder

    'Wscript.Echo subFolder

    ' Get the installation path once the recursion is done

    If InStr(1, subFolder, "08.11.09.459", vbTextCompare) > 0 Then

    TraverseFolders = USTN_APP_VERSION_SS3U2

    ElseIf InStr(1, subFolder, "08.11.09.357", vbTextCompare) > 0 Then

    TraverseFolders = USTN_APP_VERSION_SS3U1

    ElseIf InStr(1, subFolder, "08.11.09.292", vbTextCompare) > 0 Then

    TraverseFolders = USTN_APP_VERSION_SS3

    ElseIf InStr(1, subFolder, "08.11.07.443", vbTextCompare) > 0 Then

    TraverseFolders = USTN_APP_VERSION_SS2

    Else

    TraverseFolders = UKNOWN_VERSION

    End If

     Next

    End Function

    ' ---------------------------------------------------------------------

  • Jon, your suggestion worked here at home;

    vn(0) = InStr(1, subFolder, "08", vbBinaryCompare)

    vn(1) = InStr(1, subFolder, "11", vbBinaryCompare)

    vn(2) = InStr(1, subFolder, "09", vbBinaryCompare)

    vn(3) = InStr(1, subFolder, "459", vbBinaryCompare)

    If vn(0) > 0 And vn(0) < vn(1) And vn(1) < vn(2) And vn(2) < vn(3) Then

    'If InStr(1, subFolder, "08.11.09.459", vbTextCompare) > 0 Then

    TraverseFolders = USTN_APP_VERSION_SS3U2

    End If

    vn(3) = InStr(1, subFolder, "357", vbBinaryCompare)

    If vn(0) > 0 And vn(0) < vn(1) And vn(1) < vn(2) And vn(2) < vn(3) Then

    TraverseFolders = USTN_APP_VERSION_SS3U1

    End If

    vn(3) = InStr(1, subFolder, "292", vbBinaryCompare)

    If vn(0) > 0 And vn(0) < vn(1) And vn(1) < vn(2) And vn(2) < vn(3) Then

    TraverseFolders = USTN_APP_VERSION_SS3

    End If

    vn(2) = InStr(1, subFolder, "07", vbBinaryCompare)

    vn(3) = InStr(1, subFolder, "443", vbBinaryCompare)

    If vn(0) > 0 And vn(0) < vn(1) And vn(1) < vn(2) And vn(2) < vn(3) Then

    TraverseFolders = USTN_APP_VERSION_SS2

    End If

  • Unknown said:

     ' Determine Operating System

     If oFileSys.FolderExists(WinProg7) And oFileSys.FolderExists(WinData7) Then

         Osys = "Windows 7"

         PathProg = WinProg7

         PathData = WinData7

     ElseIf oFileSys.FolderExists(WinProgXP) AND oFileSys.FolderExists(WinDataXP) Then

         Osys = "Windows XP"
    ...

    Just for the purpose of information sharing, the script below is how I determine Which OS and Version a user is running, and What Bitness the OS is.  This is used in our BentleyTSGReport.txt (ftp://ftp.bentley.com/pub/tools/utilities/BentleyTSGReport.txt) data collection script.


    :: Identify Windows version - Ref: http://en.wikipedia.org/wiki/Ver_(command)#Version_list
    set OSVER=
    for /f "tokens=4 delims=[.]" %%d in ('ver') do (
    if %%d==2195 (set OSVER=WIN2000 && set OSIDX=1
    ) else if %%d==2600 (set OSVER=WINXP && set OSIDX=2
    ) else if %%d==3790 (set OSVER=WINXP64-WIN2003 && set OSIDX=3
    ) else if %%d==6001 (set OSVER=VISTA && set OSIDX=4
    ) else if %%d==6002 (set OSVER=VISTA-WIN2008 && set OSIDX=5
    ) else if %%d==7600 (set OSVER=WIN7-WIN2008R2 && set OSIDX=6
    ) else if %%d==7601 (set OSVER=WIN7-WIN2008R2-SP1 && set OSIDX=7
    ) else if %%d==9200 (set OSVER=WIN8-WIN2012-SP1 && set OSIDX=8
    ) else if %%d==9600 (set OSVER=WIN81-WIN2012R2 && set OSIDX=9
    ) else (set OSVER=UNKNOWN: %%d && set OSIDX=32768))

    :: Identify Windows architecture (64 or 32 bit)
    set OSARCH=&&set WOW6432Node=
    if defined ProgramFiles(x86) (set WOW6432Node=Wow6432Node\&& set OSARCH=64) else (set OSARCH=32)

    HTH,
    Bob



Reply
  • Unknown said:

     ' Determine Operating System

     If oFileSys.FolderExists(WinProg7) And oFileSys.FolderExists(WinData7) Then

         Osys = "Windows 7"

         PathProg = WinProg7

         PathData = WinData7

     ElseIf oFileSys.FolderExists(WinProgXP) AND oFileSys.FolderExists(WinDataXP) Then

         Osys = "Windows XP"
    ...

    Just for the purpose of information sharing, the script below is how I determine Which OS and Version a user is running, and What Bitness the OS is.  This is used in our BentleyTSGReport.txt (ftp://ftp.bentley.com/pub/tools/utilities/BentleyTSGReport.txt) data collection script.


    :: Identify Windows version - Ref: http://en.wikipedia.org/wiki/Ver_(command)#Version_list
    set OSVER=
    for /f "tokens=4 delims=[.]" %%d in ('ver') do (
    if %%d==2195 (set OSVER=WIN2000 && set OSIDX=1
    ) else if %%d==2600 (set OSVER=WINXP && set OSIDX=2
    ) else if %%d==3790 (set OSVER=WINXP64-WIN2003 && set OSIDX=3
    ) else if %%d==6001 (set OSVER=VISTA && set OSIDX=4
    ) else if %%d==6002 (set OSVER=VISTA-WIN2008 && set OSIDX=5
    ) else if %%d==7600 (set OSVER=WIN7-WIN2008R2 && set OSIDX=6
    ) else if %%d==7601 (set OSVER=WIN7-WIN2008R2-SP1 && set OSIDX=7
    ) else if %%d==9200 (set OSVER=WIN8-WIN2012-SP1 && set OSIDX=8
    ) else if %%d==9600 (set OSVER=WIN81-WIN2012R2 && set OSIDX=9
    ) else (set OSVER=UNKNOWN: %%d && set OSIDX=32768))

    :: Identify Windows architecture (64 or 32 bit)
    set OSARCH=&&set WOW6432Node=
    if defined ProgramFiles(x86) (set WOW6432Node=Wow6432Node\&& set OSARCH=64) else (set OSARCH=32)

    HTH,
    Bob



Children
No Data