Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. parse string with VBScript

parse string with VBScript

Scheduled Pinned Locked Moved Visual Basic
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kani98
    wrote on last edited by
    #1

    When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.

    Q D 2 Replies Last reply
    0
    • K kani98

      When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.

      Q Offline
      Q Offline
      quacks_a_lot
      wrote on last edited by
      #2

      You can always use the Left function to get the first part of the string if you want to be messy. VB6 Example: strTemp = SpecialFolders(Desktop) path = Left(strTemp, Len(strTemp - 7) VB.NET Example: strTemp = SpecialFolders(Desktop) path = strTmp.Substring(0, strTmp.Length - 7)

      1 Reply Last reply
      0
      • K kani98

        When I use the function SpecialFolders(Desktop), the path I back is C:\Documents and Settings\All Users\Desktop. Is there a way for me to parse this string and get only the portion "C:\Documents and Settings\All Users\" so that I can concatenate something else to it instead of "Desktop"? Thanks.

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        You don't need to do that. All you need is the value of the USERPROFILE environment variable:

        Set WshShell = WScript.CreateObject("WScript.Shell")
        ProfilePath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
        

        Dave Kreskowiak Microsoft MVP - Visual Basic

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups