amit singh
amit singh

Reputation: 23

How can I run a VB script having arguments using cmd prompt using tcl

I have a VB script which converts a csv file into xls. When this VB script is run in cmd prompt, it requires 2 arguments: path of csv file which is needed to be converted, and path of xls file where it is to be saved:

D:\csv2xlx.vbs D:\sample.csv D:\converted.xls

I want this to be executed using tcl by calling cmd prompt. When I write:

exec cmd.exe /c start D:\csv2xls.vbs D:\sample.csv D:\converted.xls

It gives an error. Can anybody suggest what is the problem?

Upvotes: 2

Views: 309

Answers (2)

Hai Vu
Hai Vu

Reputation: 40688

My machine no longer have VBScript on it, so I cannot test this out. Try:

exec cscript.exe D:\\csv2xls.vbs D:\\sample.csv D:\\converted.xls

Update: make double backslashes per Donal's suggestion.

Upvotes: 1

Donal Fellows
Donal Fellows

Reputation: 137567

The key problem you've probably got is that those backslashes are getting interpreted by Tcl instead of getting passed through. The fix is to use forward slashes and then process the filenames with file nativename during the exec:

exec cmd.exe /c start \
        [file nativename D:/csv2xls.vbs] [file nativename D:/sample.csv] \
        [file nativename D:/converted.xls]

Alternatively, use \\ instead of \ in those filenames. Or put them in braces.

exec cmd.exe /c start D:\\csv2xls.vbs D:\\sample.csv D:\\converted.xls
exec cmd.exe /c start {D:\csv2xls.vbs} {D:\sample.csv} {D:\converted.xls}

Upvotes: 2

Related Questions