文件自动拷贝到桌面及设置桌面显示此电脑

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

  

posted @ 2024-02-23 14:13  tec2019  阅读(10)  评论(0编辑  收藏  举报