Announcement

Collapse
No announcement yet.

For loop in Visual basic

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • For loop in Visual basic

    I need the following to be in VBScript

    if you can help

    Code:
    FOR /F "tokens=2* delims=	 " %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v desktop') DO SET DeskTop=%%B
    
    Echo DeskTop=%DeskTop%

    Thanks!

  • #2
    Re: For loop in Visual basic

    Here's the code to get the desktop location using VBS.

    Code:
    const HKEY_CURRENT_USER = &H80000001
    strComputer = "."
    Set oReg=GetObject( _
       "winmgmts:{impersonationLevel=impersonate}!\\" &_
        strComputer & "\root\default:StdRegProv")
    strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
    strValueName = "Desktop"
    oReg.GetStringValue _
       HKEY_CURRENT_USER,strKeyPath,strValueName,strDesktop
    WScript.Echo strDesktop
    "strDesktop" is the variable that contains the location. You can take out the Wscript.Echo line and replace it with whatever you're wanting the desktop location for.
    Regards,
    Jeremy

    Network Consultant/Engineer
    Baltimore - Washington area and beyond
    www.gma-cpa.com

    Comment


    • #3
      Re: For loop in Visual basic

      Different solutions,

      1)
      Code:
      Const DESKTOP = &H10
      
      ' http://www.cruto.com/resources/vbscr...sktop/special/
      
      Set objShell = CreateObject("Shell.Application")
      Set objFolder = objShell.Namespace(DESKTOP)
      Set objFolderItem = objFolder.Self
      strDeskTop = objFolderItem.Path
      
      wscript.echo strDeskTop
      OR,

      2)
      Code:
      Set WshShell = createobject("Wscript.Shell")
      strDeskTop = WshShell.SpecialFolders("Desktop")
      
      wscript.echo strDeskTop

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: For loop in Visual basic

        Thanks!!!!

        Comment

        Working...
        X