我遇到了返回正确输出的脚本问题:
public partial class MainWindow : Window
{
TaskViewModel viewModel = new TaskViewModel();
public MainWindow()
{
this.DataContext = viewModel;
InitializeComponent();
Server_V2.AsyncService.runMain();
DisplayAV();
}
//Display Availability
private async void DisplayAV() {
while (true) {
//availabilityField.Text = Server_V2.AV.ToString();
viewModel.Availability = Server_V2.AV.ToString();
await Task.Delay(500);
}
}
public class TaskViewModel : INotifyPropertyChanged
{
private string availabilty = "0";
public string Availability
{
get { return availabilty; }
set { availabilty = value; OnStaticPropertyChanged();}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnStaticPropertyChanged([CallerMemberName] string PropertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
}
}
由于某种原因 - 我继续回来" Maximiser Installed"和#34;提供商ID已配置"即使他们不是。我错过了一些重要的东西吗?
修改 如果找到了我的答案(因为我们有多个providerID' s) 使用:
$maximiser = Get-ChildItem -Path C:\Windows\System32\maximiser.tsp | select Name
$ID6 = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID6
$ID5 = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID5
$ID4 = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID4
$ID3 = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID3
$ID2 = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID2
$ID1 = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID1
$ID = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' | select ProviderID
$nomax = "Maximiser no installed"
$noid = "ProviderID not configured"
Write-Host 'This Computer is called' $env:COMPUTERNAME
if ($maximiser = $maximiser) {
write-host "Maxmiser installed"}
Else {write-host "$nomax"}
if ($ID6 = $ID6 ) {
write-host "Provider ID Configured"}
Elseif ($ID5 = $ID5) {
write-host "Provider ID Configured"}
Elseif ($ID4 = $ID4) {
write-host "Provider ID Configured"}
Elseif ($ID3 = $ID3) {
write-host "Provider ID Configured"}
Elseif ($ID2 = $ID2) {
write-host "Provider ID Configured"}
Elseif ($ID1 = $ID1) {
write-host "Provider ID Configured"}
Elseif ($ID = $ID) {
write-host "Provider ID Configured"}
Else {Write-Host "Provider ID not Configured"}
这似乎有效!
答案 0 :(得分:2)
Powershell中的正确表示法是“-eq”而不是“=”。
使用“=”分配值,而不是比较它。
此外,“$ something -eq $ something”永远不会评估为$ false。它总是等于它自己,即使变量根本没有值。
答案 1 :(得分:2)
像这样......
<input type="text" ng-model="vm.input.value" ng-paste="vm.pasteInput($event)" />
......当前状态应该有效。
此外,您不需要将相同的数据7次提取到不同的变量中......它会在那里。
If ($ID.ProviderID -ne $null) {
# Action if ProviderID in 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\' doesnt has a value.
}
...将导致......
$ID = Get-Itemproperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony\Providers\'
...拥有比较所需的数据。