rgdelank
New Member
- Joined
- Jun 17, 2023
- Messages
- 5
- Thread Author
-
- #1
Windows 11: I receive "access denied" by calling "Pin At Start" from the command line, no mather wich language PowerShell or VBscript.
Both are called using administrator rights.
PowerShell
==========
Error
=====
PS C:\Users\roberto> .\t.ps1
Pin-App : App(s) not found: C:\Program Files\Notepad++\notepad++.exe
In C:\Users\roberto\t.ps1:32 Zeichen:1
+ Pin-App ("C:\Program Files\Notepad++\notepad++.exe")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Pin-App
Script
=======
function Pin-App {
param(
[parameter(mandatory=$true)][ValidateNotNullOrEmpty()][string[]]$appname,
[switch]$unpin
)
$actionstring = @{$true='Von "Start" lösen|Unpin from Start';$false='An "Start" anheften|Pin to Start'}[$unpin.IsPresent]
$action = @{$true='unpinned from';$false='pinned to'}[$unpin.IsPresent]
$apps = (New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -in $appname}
if($apps){
$notfound = compare $appname $apps.Name -PassThru
if ($notfound){write-error "These App(s) were not found: $($notfound -join ",")"}
foreach ($app in $apps){
$appaction = $app.Verbs() | ?{$_.Name.replace('&','') -match $actionstring}
if ($appaction){
$appaction | %{$_.DoIt(); return "App '$($app.Name)' $action Start"}
}else{
write-error "App '$($app.Name)' is already pinned/unpinned to/from start or action not supported."
}
}
}else{
write-error "App(s) not found: $($appname -join ",")"
}
}
Pin-App ("C:\Program Files\Notepad++\notepad++.exe")
VBSCRIPT
========
Error
=====
C:\Users\Roberto>cscript.exe t.vbs
Microsoft (R) Windows Script Host, Version 5.812
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Roberto\t.vbs(37, 69) Laufzeitfehler in Microsoft VBScript: Erlaubnis verweigert.
Script
======
Option Explicit
'On Error resume next
Dim oSh, oFs, oShApp
Set oSh = CreateObject("Wscript.Shell")
Set oFs = CreateObject("Scripting.FileSystemObject")
Set oShApp = CreateObject("Shell.Application")
AmStartAnheften "C:\Program Files\Notepad++\Notepad++.exe"
Wscript.quit
Function AmStartAnheften(sProgramm)
Dim cVerbs, itemVerb, sFolder, oFolder, sFile, oFile, bAnheften
If oFs.FileExists(sProgramm) Then
'***** Do nothing, folder exists
Else
'***** Folder does not exist
bAnheften = False
WScript.Echo "File zum Anheften: " & sProgramm & " existiert nicht!!!"
WScript.Echo "Prüfen Sie die existenz der file."
Exit Function
End If
sFolder = oFs.GetParentFolderName(sProgramm)
sFile = oFs.GetFileName(sProgramm)
Err.Clear
Set oFolder = oShApp.Namespace(sFolder)
Set oFile = oFolder.ParseName(sFile)
Set cVerbs = oFile.Verbs
Err.Clear
For each itemVerb in oFile.verbs
' Verbs: PinToStartmenu, DeleteFromStartmenu, PinToTaskbar, DeleteFromTaskBar
If Replace(itemVerb.name, "&", "") = "An ""Start"" anheften" Then itemVerb.DoIt
If Err.Number <> 0 Then Wscript.Echo Err.Description & " Error."
Next
End Function
Both are called using administrator rights.
PowerShell
==========
Error
=====
PS C:\Users\roberto> .\t.ps1
Pin-App : App(s) not found: C:\Program Files\Notepad++\notepad++.exe
In C:\Users\roberto\t.ps1:32 Zeichen:1
+ Pin-App ("C:\Program Files\Notepad++\notepad++.exe")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified:
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Pin-App
Script
=======
function Pin-App {
param(
[parameter(mandatory=$true)][ValidateNotNullOrEmpty()][string[]]$appname,
[switch]$unpin
)
$actionstring = @{$true='Von "Start" lösen|Unpin from Start';$false='An "Start" anheften|Pin to Start'}[$unpin.IsPresent]
$action = @{$true='unpinned from';$false='pinned to'}[$unpin.IsPresent]
$apps = (New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -in $appname}
if($apps){
$notfound = compare $appname $apps.Name -PassThru
if ($notfound){write-error "These App(s) were not found: $($notfound -join ",")"}
foreach ($app in $apps){
$appaction = $app.Verbs() | ?{$_.Name.replace('&','') -match $actionstring}
if ($appaction){
$appaction | %{$_.DoIt(); return "App '$($app.Name)' $action Start"}
}else{
write-error "App '$($app.Name)' is already pinned/unpinned to/from start or action not supported."
}
}
}else{
write-error "App(s) not found: $($appname -join ",")"
}
}
Pin-App ("C:\Program Files\Notepad++\notepad++.exe")
VBSCRIPT
========
Error
=====
C:\Users\Roberto>cscript.exe t.vbs
Microsoft (R) Windows Script Host, Version 5.812
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Roberto\t.vbs(37, 69) Laufzeitfehler in Microsoft VBScript: Erlaubnis verweigert.
Script
======
Option Explicit
'On Error resume next
Dim oSh, oFs, oShApp
Set oSh = CreateObject("Wscript.Shell")
Set oFs = CreateObject("Scripting.FileSystemObject")
Set oShApp = CreateObject("Shell.Application")
AmStartAnheften "C:\Program Files\Notepad++\Notepad++.exe"
Wscript.quit
Function AmStartAnheften(sProgramm)
Dim cVerbs, itemVerb, sFolder, oFolder, sFile, oFile, bAnheften
If oFs.FileExists(sProgramm) Then
'***** Do nothing, folder exists
Else
'***** Folder does not exist
bAnheften = False
WScript.Echo "File zum Anheften: " & sProgramm & " existiert nicht!!!"
WScript.Echo "Prüfen Sie die existenz der file."
Exit Function
End If
sFolder = oFs.GetParentFolderName(sProgramm)
sFile = oFs.GetFileName(sProgramm)
Err.Clear
Set oFolder = oShApp.Namespace(sFolder)
Set oFile = oFolder.ParseName(sFile)
Set cVerbs = oFile.Verbs
Err.Clear
For each itemVerb in oFile.verbs
' Verbs: PinToStartmenu, DeleteFromStartmenu, PinToTaskbar, DeleteFromTaskBar
If Replace(itemVerb.name, "&", "") = "An ""Start"" anheften" Then itemVerb.DoIt
If Err.Number <> 0 Then Wscript.Echo Err.Description & " Error."
Next
End Function
Solution
The "Access Denied" error message that you are receiving when attempting to call the "Pin At Start" command from the command line may be the result of a user account control (UAC) restriction. UAC is a security feature in Windows that helps prevent unauthorized changes to your system. When you attempt to perform certain tasks that require elevated privileges, UAC prompts you for confirmation or for credentials of an administrator account.
To resolve this issue, you can try running your PowerShell or VBScript code as an administrator, which should allow you to bypass the UAC restrictions. To do this:
1. Right-click on the PowerShell or VBScript file that you want to run as an administrator.
2. Select "Run as administrator" from the...
To resolve this issue, you can try running your PowerShell or VBScript code as an administrator, which should allow you to bypass the UAC restrictions. To do this:
1. Right-click on the PowerShell or VBScript file that you want to run as an administrator.
2. Select "Run as administrator" from the...
- Joined
- Mar 14, 2023
- Messages
- 100,410
The "Access Denied" error message that you are receiving when attempting to call the "Pin At Start" command from the command line may be the result of a user account control (UAC) restriction. UAC is a security feature in Windows that helps prevent unauthorized changes to your system. When you attempt to perform certain tasks that require elevated privileges, UAC prompts you for confirmation or for credentials of an administrator account.
To resolve this issue, you can try running your PowerShell or VBScript code as an administrator, which should allow you to bypass the UAC restrictions. To do this:
1. Right-click on the PowerShell or VBScript file that you want to run as an administrator.
2. Select "Run as administrator" from the context menu.
3. If prompted by UAC, click "Yes" to grant elevated permissions.
If that does not work, you may need to modify your UAC settings to allow your scripts to execute with elevated permissions. To do this:
1. Open the Control Panel and click on "User Accounts."
2. Click on "Change User Account Control settings."
3. Move the slider to the position that you want to use for your UAC settings. If you want to allow a script to execute with elevated permissions automatically, you can select "Never notify."
4. Click "OK" to save your changes.
Note that modifying your UAC settings can have security implications, as it will allow certain programs to make changes to your system without your explicit consent. Be sure to only modify your UAC settings if you understand the risks and are confident in your ability to manage the security of your system.
To resolve this issue, you can try running your PowerShell or VBScript code as an administrator, which should allow you to bypass the UAC restrictions. To do this:
1. Right-click on the PowerShell or VBScript file that you want to run as an administrator.
2. Select "Run as administrator" from the context menu.
3. If prompted by UAC, click "Yes" to grant elevated permissions.
If that does not work, you may need to modify your UAC settings to allow your scripts to execute with elevated permissions. To do this:
1. Open the Control Panel and click on "User Accounts."
2. Click on "Change User Account Control settings."
3. Move the slider to the position that you want to use for your UAC settings. If you want to allow a script to execute with elevated permissions automatically, you can select "Never notify."
4. Click "OK" to save your changes.
Note that modifying your UAC settings can have security implications, as it will allow certain programs to make changes to your system without your explicit consent. Be sure to only modify your UAC settings if you understand the risks and are confident in your ability to manage the security of your system.
rgdelank
New Member
- Joined
- Jun 17, 2023
- Messages
- 5
- Thread Author
-
- #3
I run the scripts from a Administrator command line and no receive a message to accept changes.
The UAC are not informing me about configuration changes and i started the command lines cmd.exe or powershell.exe as administrator.
The scripts are both VBscript and Powershell and have the same behaivior. So it is not an Programm issue is more a Windows 11 setup Problemm or Security issue.
I wander how to resolve this issue. I repeat the scripts are launched with administrator rights and UAC does not react to the script.
The VBscript break before to have Err.Number set so after "On error resume next" the script do not recongnize any error.
The UAC are not informing me about configuration changes and i started the command lines cmd.exe or powershell.exe as administrator.
The scripts are both VBscript and Powershell and have the same behaivior. So it is not an Programm issue is more a Windows 11 setup Problemm or Security issue.
I wander how to resolve this issue. I repeat the scripts are launched with administrator rights and UAC does not react to the script.
The VBscript break before to have Err.Number set so after "On error resume next" the script do not recongnize any error.
rgdelank
New Member
- Joined
- Jun 17, 2023
- Messages
- 5
- Thread Author
-
- #4
I run the scripts from a Administrator command line and no receive a message to accept changes.The "Access Denied" error message that you are receiving when attempting to call the "Pin At Start" command from the command line may be the result of a user account control (UAC) restriction. UAC is a security feature in Windows that helps prevent unauthorized changes to your system. When you attempt to perform certain tasks that require elevated privileges, UAC prompts you for confirmation or for credentials of an administrator account.
To resolve this issue, you can try running your PowerShell or VBScript code as an administrator, which should allow you to bypass the UAC restrictions. To do this:
1. Right-click on the PowerShell or VBScript file that you want to run as an administrator.
2. Select "Run as administrator" from the context menu.
3. If prompted by UAC, click "Yes" to grant elevated permissions.
If that does not work, you may need to modify your UAC settings to allow your scripts to execute with elevated permissions. To do this:
1. Open the Control Panel and click on "User Accounts."
2. Click on "Change User Account Control settings."
3. Move the slider to the position that you want to use for your UAC settings. If you want to allow a script to execute with elevated permissions automatically, you can select "Never notify."
4. Click "OK" to save your changes.
Note that modifying your UAC settings can have security implications, as it will allow certain programs to make changes to your system without your explicit consent. Be sure to only modify your UAC settings if you understand the risks and are confident in your ability to manage the security of your system.
The UAC are not informing me about configuration changes and i started the command lines cmd.exe or powershell.exe as administrator.
The scripts are both VBscript and Powershell and have the same behaivior. So it is not an Programm issue is more a Windows 11 setup Problemm or Security issue.
I wander how to resolve this issue. I repeat the scripts are launched with administrator rights and UAC does not react to the script.
The VBscript break before to have Err.Number set so after "On error resume next" the script do not recongnize any error.
rgdelank
New Member
- Joined
- Jun 17, 2023
- Messages
- 5
- Thread Author
-
- #5
I stoped the defender.
I changed the UAC to not notify
I restarted the computer
I run to the same "access denied" issue.
I rerun the Scripts as Administrator again and the "Access Denied" error message is NOT resolved.
Nothing changed, i begin to thing is a bug of Windows 11
ChatGPT Please contact a Microsoft Human Windows Security specialist to check the scripts reproducing the errror looking forward for a solution.
ChatGPT Are you still therere ? Looking forward for a solution...
many thanks
I changed the UAC to not notify
I restarted the computer
I run to the same "access denied" issue.
I rerun the Scripts as Administrator again and the "Access Denied" error message is NOT resolved.
Nothing changed, i begin to thing is a bug of Windows 11
ChatGPT Please contact a Microsoft Human Windows Security specialist to check the scripts reproducing the errror looking forward for a solution.
ChatGPT Are you still therere ? Looking forward for a solution...
many thanks
Last edited: