Jump to content
Sign in to follow this  
Oddyseus1911

User Interaction on Scripts

Recommended Posts

Has anyone had any experience or success with having end users initiate or interact with scripts? 

I've used wscript.shell.popup to send messages as part of the script. Ideally it would be nice to put a shortcut on the desktop that they could run and it would start the Automate script. 

I used Automate to put a powershell script and a shortcut to it on the computer but the end user needed elevated permissions to do the update in the powershell script.

Thanks,

Grant

Share this post


Link to post
Share on other sites

I have used the following embeded in my scripts to elevate in the case of UAC. Maybe it will help you.

 

 

 

#This Section elevates to admin
param([switch]$Elevated)

function Test-Admin {
  $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
    if ($elevated) 
    {
        # tried to elevate, did not work, aborting
    } 
    else {
        Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}

exit
}

'running with full privileges'
 

Edited by Incntrl1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...