-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Arguments and Unattended Running #51
Comments
That's a good idea and shouldn't be hard to implement, though I am not sure how easy it would be to pass arguments through invoke-webrequest. At that point I would suggest removing the gui from the main script and creating a "launcher" script that if you say "command -nogui -install apps git,firefox,..." it could run the same script the gui does (at least with how I have been trying to implement the runspaces). |
After a few hours of throwing ideas at Windows Terminal, I got something that might work. Working off of the example given at https://www.codementor.io/@slavko/creating-parametrized-powershell-one-liners-rx1vk1nyc I got this using the script in my pull request:
What the code snippet does is sets the arguments to the $overrideParams variable (separate args with ;), and run the script with arguments using Invoke-Command by downloading the script and running the path using the arguments. At least that's how I think it works. Theres still a few parts of it that still look like it uses black magic though. |
That looks fairly straight forward, definitely not super easy to remember/ type in real quick. Would work in a script scenario though. I will do some research as well. I did test passing the dev environment variable in one line and it seemed to work. Might be possible to do something like this. $env:args = "nogui;install,git,firefox,..." ; iwr -useb https://christitus.com/win | iex Then have the initial script detect if that $env:args variable is set and if it is run based off that. |
Yeah that might be a better solution then the black magic I gave. The next issue will be calling the needed parts of the script based off of the arguments passed. What I did previously is split the .add_click code blocks into separate functions, then call the functions in both the argument and the accompanying .add_click code block |
Gotcha, I believe with the way I work with runspaces it shouldn't be hard to convert it to be a CLI tool as well. The way that I am doing is I make all the .add_click blocks the same and have it send the name of the button to an invoke-button function so I can control the action that way. From there and depending on the button I run another function called invoke-runspace and pass a script block variable that's defined as a variable. As long as the arguments provided in the CLI are the same as the ones provided as the GUI we can use the same script blocks and get the same results. |
Yeah, theoretically that should work. |
I created a proof of concept in pull request #52. When the script restructure is finished, I can expand the argument list to add the other Codeblocks |
Technically this feature has been added to the runspace version lol, don't know if we want to back port it to the current codebase |
I created a python script to automate winutil. It can be helpful for automating until someone has the time and the competence to implement command line parameters. |
Has there been no progress on a cli version as of yet? |
I have not had a chance yet to port over the CLI functions from the old runspace.ps1 script. |
If someone needs some basic implementations for cli; beware that tweaks that use winget may require interaction as in the gui.
|
Is your feature request related to a problem? Please describe.
It would be very useful if the script had the ability to run unattended and silent. This would be useful for people who know what they want to run and want to run a command and wait for it to finish. It would also be helpful for people like IT's and System Admins to use if they wanted to deploy the script during the setup of a network of computers.
Describe the solution you'd like
The solution would be much like what I implemented in ChrisTitusTech/win10script#331 where you pass arguments into the script and the script runs them and then exits (if the accompanying arg is set). It will be much more difficult to implement in the new variant of the script though.
I will attempt to implement it in a pull request when the current restructuring of the script for runspaces is complete as I don't want to interfere with that.
Additional context
I'm putting this here for others to refer to and offer suggestions and to prevent someone else from opening an issue on it while I'm working on it.
The text was updated successfully, but these errors were encountered: