Here's how we do it. Remember, this is an
EXAMPLE and it's up to you to change the variable names, code, and file path to suit your situation. Hope this helps...
Go to the
Job Properties and select the
Steps tab. Click
Edit. In the
Program Execution Task Properties:
Set
Target to:
cscript
Set Command-Line Parameters to:
cscript //nologo "\\celio\share\CCReportingDev\scripts\get_qclip_v1.wsf" /type:d /sbs:true
Your variables or command-line parameters are the items (in this example) /type: and /sbs: The consist of a forward slash, the parameter name you want to use, and a colon. The variable you pass in immediately follows the colon. Of course, you can have zero to many parameters along with the standard VBScript parameters.
In your code you check for what was passed in. Using my example above, here's the code that does the checking. We put the parameter code at the top of the program, right after the DIM clause(s):
If IsEmpty(wscript.arguments.named("type")) Then |
wscript.echo "Enter a value for 'type', 'd' for daily or 'w' for weekly." |
wscript.quit(2) |
End If |
|
If wscript.arguments.named("type") = "d" Then |
' sWriteLog "[Begin Daily Get_QCLIP.wsf]" |
wscript.echo "Daily QCLIP" |
Else |
' sWriteLog "[Begin Weekly Get_QCLIP.wsf]" |
wscript.echo "Weekly QCLIP" |
End If |
|
' Build the suffix to the FILE_PREFIX_DAILY. |
If IsEmpty(wscript.arguments.named("DateOfData")) Then |
dtDate = Date - 1 |
Else |
dtDate = wscript.arguments.named("DateOfData") |
If Not fMatch(DATE_PATTERN, dtDate) Then |
' sWriteLog " The format of the date entered was incorrectly." |
' sWriteLog "[End Get_QCLIP.wsf]" |
wscript.echo "The format of the date entered was incorrectly. Process stopped." |
wscript.quit(2) |
End If |
End If |
|
The key component is wscript.arguments.name("stringName")
where stringName does NOT include the forward slash nor does it include the colon. The forward slash simply lets the script know a parameter name is being passed and the colon separates the parameter name from the value being passed in.
You'll notice that I commented out writing to a log file, instead I output directly to the console. This allows me to see what's going on if I run the processes manually AND! it allows the output to be captured by ad Tempus if you set the Window Mode: to Capture Console. This way if there's an error I can check the Job Instance Details in the Captured Files tab and view the console output, helping me more quickly trouble-shoot.
I'm not a VBScript person (I normally program VBA) so I learned this
stuff on the job so please excuse me if my exact terminology is off. Good Luck!