K
K
Konkase2014-09-19 13:26:21
VBScript
Konkase, 2014-09-19 13:26:21

How to pass a variable as an argument to another program in VBS?

Good afternoon. You need to run the program with an argument. Argument is a variable from the vbs script
A piece of code:

Dim driveleter
  driveleter = Array("J:","K:","L:","M:","N:","O:","P:","Q:","R:","S:","T:")

ii=1

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run "cmd.exe /c read.cmd", 0, false
ii=ii+1

I try like this, but it doesn't work:
WshShell.Run "cmd.exe /c read.cmd driveleter(ii)", 0, false

And also tell me, is there a convenient debug for vbs in Windows? Any alternative to bash -x nix

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
omegastripes, 2014-10-24
@omegastripes

WshShell.Run "cmd.exe /c read.cmd " & driveleter(ii), 0, false

There is no native debugger. The Microsoft Script Editor from the Office kit is quite functional, you need to run the script with the //X directive on the command line, for this I personally set hot keys like "C:\WINDOWS\SysWOW64\wscript.exe" //x "$(FULL_CURRENT_PATH) in Notepad++ )". You can also look towards VbsEdit and PrimalScript.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question