powershell - Add a script for a specific choice -
i want add (small) script main script has choices. how can ?
the script want add:
*$shell = new-object -comobject wscript.shell $desktop = [system.environment]::getfolderpath('desktop') $shortcut = $shell.createshortcut("$desktop\jauns notepad.lnk") $shortcut.targetpath = "notepad.exe" $shortcut.iconlocation = "%windir%\system32\imageres.dll 98" $shortcut.save()*
and main script:
do { { write-host "" write-host "1 - selection 1" write-host "2 - selection 2" write-host "" write-host "0 - exit" write-host "" write-host -nonewline "type choice , press enter: " $choice = read-host write-host "" $ok = $choice -match '^[abcdx]+$' if ( -not $ok) { write-host "invalid selection" } } until ( $ok ) switch -regex ( $choice ) { "1" { write-host "you entered '1'" } "2" { write-host "you entered '2'" } } } until ( $choice -match "0" )
please out!
Comments
Post a Comment