uname = "$env:USERPROFILE" $uname=$uname.Substring($uname.length -8) $checkpath = test-path \\xx.xx.xxx.xxx\xx\xx\*.lnk if($checkpath -eq "True"){ copy-item \\xx.xx.xxx.xxx\xx\xx\*.* -destination \\xxx\xx$\$uname\Desktop }else{ $files = @("xx*.*","xxx.*") foreach( $f in $files){ copy-item C:\"$env:USERPROFILE"\AppData\Roaming\Microsoft\Windows\'Start Menu'\Programs'\xxx'\$f -Destination \\cnlan1snas001\Home$\$uname\Desktop } } Write-host ”拷贝快捷图标到电脑桌面”.PadRight(50),"[ " -NoNewline Write-host "完成" -ForegroundColor:Green -NoNewline Write-host " ]" echo "" sleep 3 function showComputer(){ clear-Host Write-host "在弹出的对话窗口中勾选【此电脑】然后点【确定】" -ForegroundColor:Green rundll32.exe shell32.dll,Control_RunDLL desk.cpl,0,0 #[void][System.Console]::ReadKey($true) pause } function prompt(){ write-host "是否添加【此电脑】到桌面 默认为'Y' [Y]是 [N]否 [X]退出:" -ForegroundColor:Yellow -NoNewline $cmd = read-host if($cmd -eq ''){ showComputer }elseif($cmd -eq 'Y' ){ showComputer }elseif($cmd -eq 'N'){ EXIT }elseif($cmd -eq 'X'){ EXIT }else{ write-host "输入了错误指令!" -ForegroundColor:Red clear-host prompt } } prompt
标签:cmd,桌面,xxx,电脑,host,uname,xx,拷贝到,eq From: https://www.cnblogs.com/luoye00/p/18029399