1.Periodic execution of bat file
@powershell-NoProfile-ExecutionPolicy unlimited-Command "Start-Process PowerShell.exe-Verb runas C:\********\****.ps1"
2.ps1 starts and performs actions with administrator privileges
if(!([Security.Principal.WindowsPrincipal.Security.Principal.WindowsIdentity]::GetCurrent().IsInRole("Administrators")){Start-Process powerhell.exe"-File`"$PSCommandPath`"-VerbRunAs;exit}
Set-ExecutionPolicy RemoteSigned
-- The following is the execution script:
In step 2, you can see where ps opens with administrator privileges, but the screen closes in an instant and subsequent actions are not performed.
You have permission.
It is difficult to determine the cause because it closes in an instant.
I can't find a solution to the problem.
If anyone knows anything, could you give me a hint?
Thank you for your comment.
The reason was that the path of calling ps1 from bat was garbled.
Changing the user helped solve this problem.
© 2025 OneMinuteCode. All rights reserved.