0

I am wanting to include the variable domainUser within the quoted command sent to the commandline but I am not having any luck. What I am trying to accomplish is to create a log file titled with their domain name but I keep getting errors or just getting a txt file with no title.

Dim domainUser
domainUser = Example123

objInParam.Properties_.Item("CommandLine") = "cmd /c ECHO Test >> c:\UserLogs\"""domainUser""".txt"

So line 4 would be read like this (or whatever domain user I put in on line 2)...

objInParam.Properties_.Item("CommandLine") = "cmd /c ECHO Test >> c:\UserLogs\Example123.txt"
4

1 Answer 1

1

You need concatenation to splice a variable's content into a string and double double quotes to put double quotes into it:

>> Dim domainUser
>> domainUser = "Example123"
>> Dim cmd
>> cmd = "cmd /c ECHO Test >> ""c:\UserLogs\" & domainUser &  ".txt"""
>> WScript.Echo cmd
>>
cmd /c ECHO Test >> "c:\UserLogs\Example123.txt"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.