Passing multiple arguments in vbscript

CKP 1 Reputation point

Hi There,
I have to pass multiple arguments in my .vbs script but the problem is the script does not get executed from task schedular if I pass multiple arguments separated by white spaces. I am running the script like below,

cscript//nologo D:\test\CPWinOraBackup0.100.vbs test_db D:\Oracle\WINDOWSX64_193000_db_home rman_hot D:\Oracle\DB_Backup\test_db 1> D:\test\test.log
where the syntax is as below,
cscript//nologo Script_path Oracle_home Backup_type Backup_directory retention_day
Thank you for your help in advance!

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
8,786 questions
No comments
{count} votes

1 answer

Sort by: Oldest
  1. Michael Taylor 40,926 Reputation points

    CScript requires that any arguments being passed to a script be preceded by a slash. So I wouldn't expect any of the arguments you specified outside the script name and /nologo to be forwarded to the script. So in general you would do something like this: cscript myscript.vbs //nologo /source:value /target:value. These are named arguments. You can use positional arguments but these tend to not work as well when called outside the command line.

    Another thing to consider is that if you're using Task Scheduler then there are 2 fields to be entered. The first field is the program name and that would be cscript. The second field is the arguments where you specify all the arguments to the script host. This is where your stuff needs to go. But having mentioned that then be aware that MS doesn't recommend that you try to run these scripts directly. There are problems. The recommended approach, as discussed in this old blog post is to create a command file that calls the script host instead. This would also resolve your argument issue I believe.