How to Pass Parameters to Winbatch from within Winbatch Studio
Keywords: Pass Parameters to Winbatch from within Winbatch Studio
This utility will allow you to pass parms to a winbatch script while in Winbatch Studio.To Use:
Once the Test a Script script is minimized it will work over again with any scripts. The assumptions are: a userid and password in SYbase format are the first parms and they are followed by the rest of the parms. The radio buttons allow you to place these parms at the end of your parm list if not desired which discards them.
- Open this script in Winbatch Studio and minimize
- Open the script you want to test (this is optional) if you dont open your script Test a Script will open if for you.
- RIGHT click on the minimized script (each time you want to test your script you may need to drop the watch option from VIEW then RIGHT click again on the minimized script)
- Press F5
- Fill out the parm screen. The script name must be the name of the script you desire in step 2. IF you dont want the userid and password as the first parm then check the radio button to put them last;
- Press enter or click OK
- The parm screen will disappear and a watch box will open. Press F11 (debug step command) and you will be stepping through the desired script with your parms passed to it.
The next time you run, your last script name, userid, password, userid placement, and parms will be placed in the parm screen for easy execution. They are stored in a file lasttest.txt in the current directory.
Your password is there. If you dont want to store you password there, modify this script to not read and write the password, then delete your password from the lasttest.txt file or use ? in the userid field with no password this will cause Sybase to prompt you for your userid and password.
;Written by Steve Callies ;Tested with Winbatch99 Sendkey("{alt}") Sendkey("v") Sendkey("w") Sendkey("{enter}") cdir = dirget() gosub Create_ParmPanel xScript=IniReadPvt("ParmsSection","Script","","%cdir%lasttest.txt") Userid=IniReadPvt("ParmsSection","Userid","","%cdir%lasttest.txt") pw_Password=IniReadPvt("ParmsSection","Password","","%cdir%lasttest.txt") Parms=IniReadPvt("ParmsSection","Parms","","%cdir%lasttest.txt") RunPath=IniReadPvt("ParmsSection","RunPath","","%cdir%lasttest.txt") UseridPos=IniReadPvt("ParmsSection","UseridPos","","%cdir%lasttest.txt") retval = Dialog("Parm") IniWritePvt("ParmsSection","Script",xScript,"%cdir%lasttest.txt") IniWritePvt("ParmsSection","Userid",userid,"%cdir%lasttest.txt") IniWritePvt("ParmsSection","Password",pw_Password,"%cdir%lasttest.txt") IniWritePvt("ParmsSection","Parms",Parms,"%cdir%lasttest.txt") IniWritePvt("ParmsSection","UseridPos",UseridPos,"%cdir%lasttest.txt") if useridpos == 1 if userid != "?" line=strcat(userid, "/", pw_password," ", parms) else line=strcat(userid, " ", parms) endif else line=strcat(parms," ", userid, "/", pw_password) endif Dropwild("e*") Dropwild("u*") Dropwild("p*") winactivate("WinBatch S") Sendkey("{alt}") Sendkey("v") Sendkey("w") Sendkey("{enter}") BreakPoint call("%RunPath%%xScript%.wbt", line) Exit :Create_ParmPanel ParmFormat=`WWWDLGED,5.0` ParmCaption=`Parm Control` ParmX=80 ParmY=40 ParmWidth=180 ParmHeight=100 ParmNumControls=14 Parm01=`5,3,60,DEFAULT,STATICTEXT,DEFAULT,"Enter Script Name"` Parm02=`70,3,80,DEFAULT,STATICTEXT,DEFAULT,"Enter Run Path"` Parm03=`5,10,50,DEFAULT,EditBOX,xScript,""` Parm04=`70,10,80,DEFAULT,EditBOX,RunPath,""` Parm05=`5,27,100,DEFAULT,STATICTEXT,DEFAULT,"Enter Userid"` Parm06=`50,27,100,DEFAULT,STATICTEXT,DEFAULT,"Password"` Parm07=`100,27,90,DEFAULT,RADIOBUTTON,useridpos,"User/Pass &Before Parms",1` Parm08=`100,37,90,DEFAULT,RADIOBUTTON,useridpos,"User/Pass &After Parms",2` Parm09=`5,34,40,DEFAULT,EditBOX,userid,""` Parm10=`50,34,40,DEFAULT,EditBOX,pw_password,""` Parm11=`5,49,100,DEFAULT,STATICTEXT,DEFAULT,"Enter Parm String"` Parm12=`5,56,150,DEFAULT,EditBOX,parms,""` Parm13=`20,80,44,DEFAULT,PUSHBUTTON,DEFAULT,"&Ok",1` Parm14=`110,80,50,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0` Return
Article ID: W14493Filename: Pass Params in Winbatch Studio.txt