All Forums >> [Scripting] >> WSH & Client Side VBScript >> enclose double quotes around a variable Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
I am having a strange kinda problem. I want to execute a dos command from vbscript which has a variable enclosed in quotes.
Lets say something like cmd \c dir | find "abc.txt" now this abc.txt is a variable that I am reading from somewhere else. Now the problem is I don't seem to be able to do it. If I add """ around it then it takes the literals and there doesn't seem to be any way of adding quotes around a variable and running it.
Hi, thanks a lot for this one. Now this solves my problems to a great extent. The next doubt I have is whether and how can I take the output of this command in a variable in the script sothat I can compare the output and directly miplement my logic. What I am doing right now is writing this to a txt file and reading from there which is awfully slow! :(
I will tell you the entire requirements, as VBA and VBScript are quite nearby I am using this approach. I have a spreadsheet that looks something like this -
quote:
s.no. name of the entitiy server run site 1 abcde ldnpsm123456
now, i run a command as
quote:
sfmontyd -s <server name> live list | find "name of the entity"
to this, if i get a blank row then i have to make it red otherwise green. Now, my first hurdle was to enclose the name of the entity in quotes, so I was writing the opt to the file and scanning. Now, that part is done so the next thing is I want to capture the output to a variable and take the first word of the output and compare it with the name entity, if it matches then i make it green otherwise red. As I have about 500 such rows for which this is to be checked, the file mechanism must be removed as it makes the program very slow. I read something about exec method in vbscript. Does it exist in VBA too and how should I go about now?