Windows Vista Forums

quotes and variables
  1. #1


    ylafont Guest

    quotes and variables

    I am wondering if someone can clarify the proper use of the oShell.run
    command at the bottom of the sample script below. I am importing a registry
    file via WSH. The name of the file is in long format as indicated by the
    stmpFile variable. Since the file name will be different for every user, I
    want to pass the variable name instead of the file name. However the long
    format is not allowing the import. I know I have to pass the quotes along
    with the variable. I have tried several syntax however, none of which have
    worked. Can anyone assist?

    sTmpFile = "c:\Some long Name.reg"



    ' Write to the temporary registry file
    fFile.WriteLine "Windows Registry Editor Version 5.00"
    fFile.WriteLine
    fFile.WriteLine
    "[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\UserInfo]"
    fFile.WriteLine """UserName""=hex:" & strUsernameHex
    fFile.WriteLine """UserInitials""=hex:" & strInitialsHex
    fFile.Close

    oShell.Run "regedit /s " & sTmpFile, 0, True


      My System SpecsSystem Spec

  2. #2


    Old Pedant Guest

    RE: quotes and variables


    oShell.Run "regedit /s """ & sTmpFile & """", 0, True

    In VBScript, you use a PAIR of " marks inside a string to indicate an
    embedded quote.

    You could also use

    oShell.Run "regedit /s " & CHR(34) & sTmpFile & CHR(34), 0, True

    CHR(34) is just a conversion of the number 32 to its ASCII equivalent, which
    is indeed the quote mark.




      My System SpecsSystem Spec

  3. #3


    ylafont Guest

    RE: quotes and variables

    you know, I dont knwo where my head was, since i have used this in the
    past. thank you for the quick response.

    "Old Pedant" wrote:

    >
    > oShell.Run "regedit /s """ & sTmpFile & """", 0, True
    >
    > In VBScript, you use a PAIR of " marks inside a string to indicate an
    > embedded quote.
    >
    > You could also use
    >
    > oShell.Run "regedit /s " & CHR(34) & sTmpFile & CHR(34), 0, True
    >
    > CHR(34) is just a conversion of the number 32 to its ASCII equivalent, which
    > is indeed the quote mark.
    >
    >
    >

      My System SpecsSystem Spec

quotes and variables problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
math with "GB/MB/KB" in variables fails, without variables works? James R. Gentile PowerShell 2 01 Nov 2008
Sundeep Raina:) variables being handled in Workflow and How to declare New Variables raisundeep@gmail.com WinFX General 1 09 Aug 2006
Sundeep Raina(Iopsis): Is variables being handled in Workflow and How to declare New Variables sunny Avalon 0 30 Jun 2006