Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts

    Automate creation of scheduled task and shortcut to circumvent UAC

    Hey Y'all,

    In response to Woody's column on getting around UAC and the comments made in the Windows Secrets Forum I decided to write a PS script to automate the process. As those of you who frequent this forum I'm just learning PS and as such would appreciate your comments on the code and ways to make it better. Thanks for looking.

    Create-NoUACTaskShortcut.zip

    HTH
    Last edited by RetiredGeek; 2014-12-03 at 14:19. Reason: Updated Code & Documentation to Vers 1.3
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  2. #2
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Dear RG (I'm a SemiRG myself),

    I followed your link and downloaded the zip here, extracted the files, and read the documentation - seems simple enough.

    Then I clicked on the program file and saw it simply open up in a text editor.

    So I've been trying to find a place to download a version of Windows PowerShell that runs on my 32 and 64 bit Win 7 Pro SP1 machines.

    Though Microsoft.com is delighted to link me to documentation, it sends me in circles trying to find the downloads. Could you supply links to download versions for Win 7 Pro SP1 /32 and 64 bit versions of the OS?

  3. #3
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Found the page with the download links: http://www.microsoft.com/en-us/downl....aspx?id=34595

  4. #4
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Installed Windows PowerShell, right-clicked on your program, and chose Run with PowerShell.

    A console window, resembling a DOS prompt, opened, with a multi-line message in red type on the black background, and closed in less than half a second before I could read any of it.

    Tried this multiple times with the same result every time.

  5. #5
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,723
    Thanks
    146
    Thanked 156 Times in 149 Posts
    I tried this. I searched for powershell (via the win 8 start screen - magic!). I right clicked the exe and chose run as administrator. I then navigated to where I had saved the script and ran it (all done as if it was a dos command window). I can read the text it produces but it says that running scripts is disabled on this system. I thought I had run some scripts before so I'm not sure what may have changed. I'm just about to investigate further.

  6. #6
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Hey Y'all,

    Sorry I guess I should have included this link on setting up PowerShell for the first time. By Default PowerShell is locked down for security.

    Setting up PowerShell See Post #2 Items 1-3.

    Note: The instructions are for the PowerShell_ISE (Integrated development environment). You may also need to set the ExecutionPolicy for the PowerShell command line environment. To do this just enter PowerShell.exe vs PowerShell_ISE.exe in the search box.

    HTH
    Last edited by RetiredGeek; 2014-11-25 at 07:17.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. #7
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Stumped!

    I did what it said in items 1 & 2 of that post, agreed to the policy change, and was told I wasn't allowed access to that registry key:

    Set-ExecutionPolicy : Access to the registry key
    'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\ 1\ShellIds\Microsoft.PowerShell' is denied.
    At line:1 char:2
    + Set-ExecutionPolicy RemoteSigned
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: ( [Set-ExecutionPolicy], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Power Shell.Commands.SetExecutionP
    olicyCommand

    (No, I didn't put in a smiley - this board did.)

    The response to step 3 was more terse: "Restricted"

    I then searched for PowerShell.exe, ran that, and entered the same command at its command prompt, agreed to the change, and got precisely the same error message.

    And yes, I'm running in an account with full administrator privileges, which is a member of the Administrators group, which the Microsoft instruction page "Getting Ready to Use PowerShell" says is required.

    It appears that I'm allowed to run Get-ExecutionPolicy, but not Set-ExecutionPolicy - or at least not change anything with it. I can start it with no parameter, but once it's up, anything I say inside of it is rejected as unauthorized.

    I've never used the Group Policy system, and this is a new machine, so there's no policy editor, much less any policies in place!

  8. #8
    Lounger
    Join Date
    Dec 2009
    Location
    Gillingham, Dorset, UK
    Posts
    30
    Thanks
    0
    Thanked 13 Times in 11 Posts
    Philnick,

    When you ran Powershell, did you choose the option "Run as administrator"?

    To change the execution policy you need to start Windows PowerShell with that option.

    HTH

  9. #9
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That worked - but it's a bit unintuitive that even though there's a badge next to that option on the shortcut's properties (I pinned it to my taskbar) I have to click on that option to make it happen!

  10. #10
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can now get the program to run, but only by right-clicking on the ps1 file - setting up a shortcut to it as your outlined in the thread from which I got your program - and starting that shortcut with administrative privileges still is blocked!

    So I'll set up a shortcut to that folder.

  11. #11
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    PhilNick,

    Use the program to setup bypassing UAC for itself:

    Task/Shortcut Command: C:\Windows\system32\WindowsPowerShell\v1.0\PowerSh ell.exe
    Task/Shortcut Args: your-drive-letter-here:\your-path-here\Create-NoUACTaskShortcut.ps1

    To use an icon from Windows: C:\Windows\System32\SHELL32.dll,n where n is the icon number.
    Or just check the Use Task/Shortcut Command Icon: option.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  12. #12
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by RetiredGeek View Post
    PhilNick,

    Use the program to setup bypassing UAC for itself:

    Task/Shortcut Command: C:\Windows\system32\WindowsPowerShell\v1.0\PowerSh ell.exe
    Task/Shortcut Args: your-drive-letter-here:\your-path-here\Create-NoUACTaskShortcut.ps1

    To use an icon from Windows: C:\Windows\System32\SHELL32.dll,n where n is the icon number.
    Or just check the Use Task/Shortcut Command Icon: option.
    Doesn't work. I fill in the name, command, and argument boxes, and check use the command icon, and the PowerShell window puts up a multiline red error message and disappears too fast to see what it said.

    By the way, I tested your script out by trying to create a task and shortcut for a run-of-the-mill program located under "Program Files."

    Your script does not work either with or without quotes in the Task/Shortcut Cmd box, to deal with the space in the path in the phrase "Program Files." With the quotes, your script complained that what I put in was invalid. Without them, PowerShell did its multiline red error message disappearing act.

    By the way - is there any way to keep it from doing that. Can't it be told to stay on screen so I can read the error message?

  13. #13
    New Lounger
    Join Date
    Nov 2011
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've set the execution policy back to restricted. No point leaving a back door open when I don't have any script to run!

  14. #14
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Philnick,

    If you set it to RemoteSigned you don't have to worry about external programs.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  15. #15
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Hey Y'all,

    I've updated the zip file in the Post #1 to include an updated documentation file that incorporates instructions on getting PowerShell to work the first time (per your comments above) and using the program to create a shortcut to itself. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •