『楼 主』:
Powershell 运行问题
使用 LLM 解释/回答一下
各位大侠:
我运行如下的脚步程序:
cmd /c powershell.exe -WindowStyle Hidden -NonInteractive -command {$hklm = "HKEY_LOCAL_MACHINE" ;$key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Wireless-101_is1" ;$value = "InstallLocation" ;$a=([Microsoft.Win32.Registry]::GetValue("$hklm\$key",$value,$null) + 'bin\App.exe') ;& $a}。
该脚本的作用是通过查询注册表,然后在运行安装路径下的应用程序。
现在的问题是:如果在Win7下运行Powershell,进入Powershell那个界面后,运行这个脚步是OK的,可以正确的调用应用程序。
但是:如果在win7中运行cmd,进入普通命令行界面,运行这个脚步就有问题。
如果在cmd界面中,先运行一次 cmd /c powershell命令后,再运行这个脚步也没有问题。
盼望各位大侠赐教!
Dear great experts:
I run the following script:
cmd /c powershell.exe -WindowStyle Hidden -NonInteractive -command {$hklm = "HKEY_LOCAL_MACHINE" ;$key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Wireless-101_is1" ;$value = "InstallLocation" ;$a=(::GetValue("$hklm\$key",$value,$null) + 'bin\App.exe') ;& $a}。
The function of this script is to query the registry and then run the application in the installation path.
Now the problem is: If it is run in PowerShell under Win7, after entering the PowerShell interface, running this script is OK, and the application can be called correctly.
But: If it is run in cmd in Win7, entering the normal command line interface, running this script has problems.
If in the cmd interface, run the cmd /c powershell command once first, and then run this script, there is no problem.
Hope that great experts can give advice!
|