PerryRaptor Posted February 17, 2004 Share Posted February 17, 2004 Having trouble coming up with modular code that can accept any number of CmdLine[x] parameters to be included in a RunWait() command. I use VBscript during the logon process for a number of tasks. I want the ability to pass any number of command line switches to a compiled AutoIT3 script, leveraging the RunAsSet() function on remote workstations. WshShell.Run "\\NetworkShare\AU3program.exe Myprogram.exe /A /F /K /Q ", 1, TRUE AU3program.exe needs to execute MyProgram.exe and any trailing switches in a RunWait() construct. Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 (edited) Untested... $szLine = "" For $i = 1 To $CmdLine[0] $szLine = $szLine & $CmdLine[$i] If $i < $CmdLine[0] Then $szLine = $szLine & " " Next ; $szLine is now a string with all command line arguments passed. RunWait("path\to\program.exe " & $szLine) Edited February 17, 2004 by Valik Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 17, 2004 Author Share Posted February 17, 2004 Will I need to add & " " & between $szLine & $CmdLine[$i] to have a space between each parameter? I can test it tomorrow using MSGBOX()...Head hursts from coding... Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 That's already being done by: If $i < $CmdLine[0] Then $szLine = $szLine & " " which appends a space at the end of each argument except the last one. Link to comment Share on other sites More sharing options...
trids Posted February 17, 2004 Share Posted February 17, 2004 ...I want the ability to pass any number of command line switches to a compiled AutoIT3 script...Be aware that there appears to be some kind of OS-imposed constraint on passing $CmdLine[] parameters. Probably depends on the total byte-size of the passed parameters, rather than the number of them. I'm still stuck with this problem in a SendTo tool that takes a selection of files and places their pathnames on the clipboard. Looks like 300-400 Kb is the ceiling. http://www.hiddensoft.com/forum/index.php?showtopic=426 Link to comment Share on other sites More sharing options...
PerryRaptor Posted February 18, 2004 Author Share Posted February 18, 2004 Valik, I shouldn't have replied last night being tired an all. I saw the & " " this morning and felt dumb. :iamstupid: Thanks for passing on the string size issue Trids. I invision the string will be less than 100 characters in size. I would expect that needing more than 100-150 characters would require GUI implementation or numerous inputboxes to effectively manage such a large undertaking. I never considered $CmdLine[x] as an array. The help file didn't lead me to think it was until looking at Valik's code with fresh eyes and mind this morning. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now