'powershell script not working but codes are working?
$CSharpSig = @'
[DllImport(“user32.dll”, EntryPoint = “SystemParametersInfo”)]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam,
uint pvParam,
uint fWinIni);
'@
$CursorRefresh = Add-Type -MemberDefinition $CSharpSig -Name WinAPICall -Namespace SystemParamInfo –PassThru
$CursorRefresh::SystemParametersInfo(0x0057,0,$null,0)
- this script refreshs mouse cursor
- if you run this script will not work !
- but if you copy & Paste the codes in powershell
- it will work !
- I don't know how
Solution 1:[1]
Your issue is likely related to the character encoding, maybe due to the ps1 being saved without a BOM as VS likes to do, so your quotes are being misinterpreted.
To quickly test, copy/paste this line into your code instead and I bet it'll work fine.
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mike Anthony |
