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

RE: quotes and variables by OldPedant

OldPedant
Tue Jul 15 20:15:02 CDT 2008


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.




RE: quotes and variables by ylafont

ylafont
Wed Jul 16 08:03:15 CDT 2008

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.
>
>
>