This topic contains 3 replies, has 2 voices, and was last updated by
December 2, 2017 at 7:23 am #85348ParticipantPoints: 1Rank: Member
I have done 'shell:startup' in the Run box and created a shortcut to PowerShell there but it never starts! I am using ...powershell.exe -NoExit -WindowsStyle minimized. If I click this shortcut manually then it runs, so what is missing please?
(It also works but only if I uncheck the Run As Administrator box in the shortcut properties, but this is not what is required.)
December 3, 2017 at 1:36 am #85354ParticipantPoints: 512Rank: Major Contributor
I am not sure of your goal here.
So, if you have this as a shortcut on your desktop / taskbar. Why are you going to the Run dialog box?
That seems a bit counterintuitive.
Like you said, you can just click the shortcut and it works. You, of course could also, just assign it a shortcut keyboard as well.
On my default Win10 rig, shell:startup, opens Windows Explorer to the current user '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup'. Just as it would if one did it directly in the Windows Explorer input box.
Is your goal to override this for some reason?
December 3, 2017 at 6:16 am #85355ParticipantPoints: 1Rank: Member
I am trying to start an Admin PowerShell Session when the computer starts, that is all. I was trying to use shell:startup to create the shortcut there but it fails; so I have done a workaround: Create a scheduled task (Logon) using ...powershell.exe -NoExit -WindowsStyle minimized -ExecutionPolicy remotesigned. Then check the Run With Highest Privileges box and an Admin PowerShell session is created.
My question is why is this failing if I put a shortcut for this in the Startup folder?
December 4, 2017 at 5:41 am #85369ParticipantPoints: 512Rank: Major Contributor
Yea, that whole throwing things in that folder like we used to do back in the day, on Windows 10 is really not much of a thing that I've seen folks do or want to do any more.
That's not saying it should not work however, well, with the exception to how .lnk files are handled. Meaning, they are not executables, and the Startup folder is looking for .cmd, .bat, .com ,.exe.
Like the workaround (Logon scripts) you decided to go with, that is what I've been using since Windows 7 SP1, because I can do this via GPO directly to system in my lab.
Others have been taking that route as well. See...
There are other ways of course to do this other than using the startup folder or scheduled task.
Yet, that means hacking at the registry...
...and the other work around if you are insistent on the Startup folder, is to create a .cmd or .bat file that uses the good old DOS start command to fire off your shortcut.
So, say create a start.cmd file, located in the StartUp folder with your shortcut, which contains...
cd "C:\Users\...\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
... or whatever other program(s) you wish to start that has a shortcut there.
Point of Note:
Notice, the no spaces allowed in the PoSH shortcut name and note in the .cmd file, there is no extension on the shortcut, though the shortcut of course does. If you put one in that command in that .cmd file, it will fail.
...and scheduled task is just more direct and prudent IMHO.
The topic ‘Windows 10: start PowerShell session at Startup as Admin.’ is closed to new replies.