带有消息框的PowerShell脚本不会显示在远程计算机上

时间:2018-03-21 08:51:05

标签: powershell batch-file

这是我的剧本:

key

我是通过我的公司程序在远程计算机上使用此命令启动它,并使用批处理(CMD)管理权限运行它:

$name = function Get-Name {
    $env:computername
}
Get-Name

$time = function Get-SystemUptime {
    $operatingSystem = Get-WmiObject Win32_OperatingSystem
    "$((Get-Date) - ([Management.ManagementDateTimeConverter]::ToDateTime($operatingSystem.LastBootUpTime)))"
}
Get-SystemUptime

$string = Get-SystemUptime
$separator = "\."
$string.Split($separator, 2)

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
Add-Type -AssemblyName PresentationFramework
Add-Type –AssemblyName System.Windows.Forms

$days = $string.Split(".")[0]
if ([convert]::ToInt32($days, 10) -ge 1) {
    $MsgboxTxt = "TXT $($days) TXT"
    $MsgboxTitle = '!!! TXT !!!'
    [System.Windows.Forms.MessageBox]::Show($MsgboxTxt, $MsgboxTitle, [Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Stop, [System.Windows.Forms.MessageBoxDefaultButton]::Button1, [System.Windows.Forms.MessageBoxOptions]::DefaultDesktopOnly)
}

当我通过复制文件在本地计算机上运行并从CMD在本地priveliges运行时,它没问题。一切正常。

我认为我的公司程序(LOGSystem)在管理用户上运行它,而不是登录用户。

是否可以选择使用CMD命令在已登录的用户上运行它?

0 个答案:

没有答案
相关问题