FN-GM Posted September 10, 2018 Posted September 10, 2018 Hello, I am looking to create a basic script that will display 3 options on screen. The technician will pick one and based on that option a file will copy and a .exe will launch. The file and .exe will be unique to each option. Can someone who knows more about script than me please help? Thanks
ThomL Posted September 10, 2018 Posted September 10, 2018 (edited) All doable with powershell if this is needed on a windows system? You could even gui it up a little - something like this: threeOptions.ps1 Edited September 10, 2018 by ThomL 1
stevec_ Posted September 10, 2018 Posted September 10, 2018 Something like this should work, just edit as necessary $File1 = "" $EXE1 = "" $File2 = "" $EXE2 = "" $File3 = "" $EXE3 = "" $GetSelection = { $Selection = Read-Host -Prompt "Please choose an option: 1. File 1 and EXE 1 2. File 2 and EXE 2 3. File 3 and EXE 3" switch ($Selection) { 1 { Copy-Item $File1 -Destination "c:\CopyToHere" & $EXE1 } 2 { Copy-Item $File2 -Destination "c:\CopyToHere" & $EXE2 } 3 { Copy-Item $File3 -Destination "c:\CopyToHere" & $EXE3 } default { .$GetSelection } } } .$GetSelection 1
FN-GM Posted September 11, 2018 Author Posted September 11, 2018 (edited) Something like this should work, just edit as necessary $File1 = "" $EXE1 = "" $File2 = "" $EXE2 = "" $File3 = "" $EXE3 = "" $GetSelection = { $Selection = Read-Host -Prompt "Please choose an option: 1. File 1 and EXE 1 2. File 2 and EXE 2 3. File 3 and EXE 3" switch ($Selection) { 1 { Copy-Item $File1 -Destination "c:\CopyToHere" & $EXE1 } 2 { Copy-Item $File2 -Destination "c:\CopyToHere" & $EXE2 } 3 { Copy-Item $File3 -Destination "c:\CopyToHere" & $EXE3 } default { .$GetSelection } } } .$GetSelection Thanks for this. It looks ideal. I am using this code Copy-Item $File1 -Destination "APPDATA" However it is trying to send the file to the desktop. This is where the script file is located. I am expecting it to put it in: "C:\Users\\AppData\Roaming\file.pb" Any thoughts please? - Thanks Edited September 11, 2018 by FN-GM
Arthur Posted September 11, 2018 Posted September 11, 2018 I am using this code Copy-Item $File1 -Destination "APPDATA" This should work... Copy-Item "$File1" -Destination "$env:APPDATA\file.pb" 1
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