我正在尝试做一个非常简单的代码来检测笔记本电脑架构。下面是代码。我的笔记本电脑是64位的,但它也会显示32位的消息框。我在代码中还遗漏了什么吗?
#Load assembly
add-type -assemblyname system.windows.forms
#Assign messagebox to variable
$message1 = [System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
$message2 = [System.Windows.Forms.MessageBox]::Show("This is a 32 bit version" , "Status")
#Display message based on the architecture
if ([System.Environment]::Is64BitProcess) {
echo $message1
} else {
echo $message2
}发布于 2017-02-07 16:30:46
您的消息框在变量声明时正在运行,您可以通过运行$x = [System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")语句来确认这一点。only.show方法显示消息框并将消息的响应(本例中为“ok”)存储在变量中,尝试如下:
#Load assembly
add-type -assemblyname system.windows.forms
#Display message based on the architecture
if ([System.Environment]::Is64BitProcess) {
[System.Windows.Forms.MessageBox]::Show("This is a 64 bit version" , "Status")
} else {
[System.Windows.Forms.MessageBox]::Show("This is a 32 bit version" , "Status")
}https://stackoverflow.com/questions/42081748
复制相似问题