Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quotes within quotes 3

Status
Not open for further replies.

brian32

Vendor
Mar 20, 2005
35
0
0
US
I want to run the following cacls command in vbscript:

cacls "C:\Program Files\My Program" /T /E /G "Authenticated Users":C

The objShell.Run command already uses quotes so how can I implement my command so that the two don't conflict? How can I put quotes withing quotes? Thanks.
 
Use two "" or Chr(34)
My preference is Chr(34).
For example:

"cacls " & Chr(34) & "C:\Program Files\My Program" & Chr(34) & " /T /E /G " & Chr(34) & "Authenticated Users" & Chr(34) & ":C"

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
If I wanted to use this on a remote computer, the command would be:

cacls "\\RemoteComputer\C$\Program Files\My Program" /T /E /G "Authenticated Users":C

If the variable for the remote computer is strComputer, what would I need to do in order to accomodate the \\, and what would the final command look like?
 
objShell.Run "cacls ""\\" & strComputer & "\C$\Program Files\My Program"" /T /E /G ""Authenticated Users"":C"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Coming from other script languages, this part of VBS annoyed me so much that I made a function to handle it:

objShell.Run "cacls " & qq(""\\" & strComputer & "\C$\Program Files\My Program") & " /T /E /G " & qq("Authenticated Users") & ":C"

Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top