#170448 - 2006-11-20 05:48 AM
New Switch to support Free style Command Line arguments
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Currently, kix32.exe only accepts variables in the format of $var="blah", a few predefined switches, and/or additional script names as arguments. If you try to provide any other type of argument, it causes an error.
With the current addition of the getcommandline() function, I would like to suggest adding another switch to kix32.exe that would allow you to use your own structure for arguments. For example: Code:
kix32 /o script.kix [Open/Other arguments]
Once the /o switch is set to kix32.exe, it would allow the user to define variables in the format they choose, and they would have to handle the variables in the code via the getcommandline() function.
In the mean time I did find a workaround that would allow some degree of open arguments, but it requires that the script end with "Quit" to keep it from trying to run the arguments as scripts. For example:
kix32 script.kix 1234567890 abc edf
Code:
break on for each $arg in getcommandline(1) ? $arg next
quit 0
Returns: Quote:
kix32 script.kix 1234567890 abc edf
|
Top
|
|
|
|
#170452 - 2006-11-20 10:02 AM
Re: New Switch to support Free style Command Line arguments
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
No need for the Quit:
Code:
Break On For Each $arg in GetCommandline(1) If Left($arg,1)="$$" "Argument: "+SubStr($arg,2)+@CRLF EndIf Next
You just need to prefix your switch with a "$". Consider the following, which in order comprises a simple switch, a complex switch with a parameter and a bare parameter value:
Quote:
C:\Temp>kix32 cl.kix $/s $/p:"A switch with a parameter" $asimpleparameter Argument: /s Argument: /p:A switch with a parameter Argument: asimpleparameter
Using the "/" means that there is no chance of a variable namespace clash.
|
Top
|
|
|
|
#170454 - 2006-11-20 01:45 PM
Re: New Switch to support Free style Command Line arguments
|
Benny69
Moderator
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
I like the idea. This probably does not work right now, but it seams more intuitive: Code:
$args = split(GetCommandline(),"/")
Edited by Benny69 (2006-11-20 02:26 PM)
|
Top
|
|
|
|
#170456 - 2006-11-21 09:43 PM
Re: New Switch to support Free style Command Line arguments
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Yes, but we know you come from a different background
I'm not saying one can't use or come up with ideas, methods for it's use, just curious why/how normal admins would use it.
I've been scripting now for quite a while and I've so far managed to run my scripts without it. Doesn't mean maybe I couldn't be more efficient though I suppose, just most scripts are one offs. Those that run often are typically already either part of Logon script, or the script contains all it needs to know to complete the task.
But hey if there is a real need for it then that's great, I hope Ruud listens to the suggestion.
|
Top
|
|
|
|
#185733 - 2008-02-26 06:52 PM
Re: New Switch to support Free style Command Line arguments
[Re: Lonkero]
|
duo
Getting the hang of it
Registered: 2007-10-25
Posts: 61
Loc: iowa
|
I love this idea, when i am at a remote site on our domain i dont like to sit there for 5 minutes waiting for drives,printers,etc to map. I can use this as a kill switch of sorts, prompting to ask if i want to do certain tasks or not.
Break On
For Each $arg in GetCommandline(1)
If Left($arg,1)="$$"
$cmd_arg=SubStr($arg,2)
EndIf
if $cmd_arg='administrator'
? "ITS OVER NINE THOUSAND"
endif
Next
|
Top
|
|
|
|
#185736 - 2008-02-26 07:28 PM
Re: New Switch to support Free style Command Line arguments
[Re: Glenn Barnas]
|
duo
Getting the hang of it
Registered: 2007-10-25
Posts: 61
Loc: iowa
|
maybe, but hopefully your not trying to map a drive to servers 10 miles away from the location. The logic is not the problem its just windows. In house it takes approx 3-4 seconds
Edited by duo (2008-02-26 07:28 PM)
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 557 anonymous users online.
|
|
|