How can we help?
-
Microsoft 365
-
Cybersecurity | Linux
-
- Articles coming soon
-
- Articles coming soon
-
DEV
-
- Articles coming soon
-
- Articles coming soon
< All Topics
Elementor KB Article
0 out of 5 stars
5 Stars | 0% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
PHP
//hello world function
function hell_world( $post_type_params ) {
$post_type_params['hierarchical'] = true;
if ( empty($post_type_params) ) {
helper();
}
return 'success';
}
Add Your Heading Text Here
Advanced Heading Title
Copy the URL link to this section to share
PHP
//hello world function
function hell_world( $post_type_params ) {
$post_type_params['hierarchical'] = true;
if ( empty($post_type_params) ) {
helper();
}
return 'success';
}
PowerShell
<#
https://learn.microsoft.com/en-us/troubleshoot/windows-client/admin-development/create-desktop-shortcut-with-wsh
https://stackoverflow.com/questions/63287152/value-does-not-fall-within-expected-range-when-applying-property-to-windows-10-s
#>
function Add-CapAdminShortCut {
[CmdletBinding()]
param (
[Parameter(Mandatory, Position=1)]
[string]$AppName,
[Parameter(Mandatory,Position=2)]
[string]$ExePath
)
$ShortcutName = $AppName + ' As Admin'
$AppExePath = $ExePath
$principalID = $Env:UserDomain + '\' + $Env:USERNAME
$RandomPrefix = Get-Random -Minimum 111 -Maximum 999
$TaskName = $AppName + ' - AdminExecTask - ' + $RandomPrefix
if (Test-Path $AppExePath){
#exepath exists so continue
<# CREATE TASK #>
$action = New-ScheduledTaskAction -Execute $AppExePath
$principal = New-ScheduledTaskPrincipal -UserID $principalID -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Principal $principal -Settings $settings
Register-ScheduledTask $TaskName -InputObject $task
<# CREATE SHORTCUT #>
$TaskCmd = 'C:\Windows\system32\schtasks.exe'
$TaskArgs = ' /run /TN ' + '"' + $TaskName + '"'
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\$ShortcutName.lnk")
$Shortcut.TargetPath = $TaskCmd
$Shortcut.Arguments = $TaskArgs
#windowstyle is not working
$Shortcut.WindowStyle = 0 #&&Minimized 0=Maximized 4=Normal
$Shortcut.IconLocation = $ExePath
$Shortcut.Save()
} else {
Write-Error "Exe Path is not correct. Please check."
return
}
Write-Host "Task and Shortcut are created succefully."
}
Was this article helpful?
0 out of 5 stars
5 Stars | 0% | |
4 Stars | 0% | |
3 Stars | 0% | |
2 Stars | 0% | |
1 Stars | 0% |
5
Table of Contents