Jump to content

How to run Snipping tool as Administrator?


Recommended Posts

#AutoIt3Wrapper_UseX64=y
$sFile = ("C:\WINDOWS\system32\SnippingTool.exe")
If FileExists($sFile) Then
   ShellExecute($sFile)
Else
   MsgBox(0,'File Error', "The Windows snipping tool was not found")
EndIf

I am using this Code to open SnippinTool becouse i have to make screen shots for my job. But when i do Screen shot on my computer and i am trying to save it it says i dont have permission for it. When i open program by myself everything works... Please help

Link to comment
Share on other sites

Hey Huntknife,

Your script works alright for me. Some considerations:

1. Is it possible you have UAC off?

2. When you open a CMD prompt as normal (RUN +S - cmd) does it start from your userprofile (i.e., C:\Users\<name>) or some other directory?

3. What is the operating system (Win7/10 etc.)?

 

Try using "Run()" instead of "ShellExecute()" before going further down.

#AutoIt3Wrapper_UseX64=y
$sFile = ("C:\WINDOWS\system32\SnippingTool.exe")
If FileExists($sFile) Then
   ;ShellExecute($sFile)
    run($sFile)
Else
   MsgBox(0,'File Error', "The Windows snipping tool was not found")
EndIf

 

If unsuccessful, continue reading.

Can you try with this batch script? Start this batch from your script if it works. Write "Rem" to the start of the line to comment it out. Delete "REM" to make it effective. The last commented line is the runas admin one. Please read the links before enabling local admin account. Try first using your own account before trying local admin account.

Note: Add "/savecred" switch after "/username:<name>" in order not to get the password prompt each time. Before saving your creds, consider if anyone else has access to your user account.

External websites you might be interested in:

https://www.zdnet.com/article/windows-10-tip-how-to-enable-the-built-in-administrator-account-and-why-you-shouldnt/

https://www.tenforums.com/tutorials/63827-run-different-user-windows-10-a.html

https://ss64.com/nt/runas.html

Save as <filename-of-your-choice>.bat and start this file instead. Right-click and open/edit with notepad to edit it.

@ECHO ON
C:
"C:\WINDOWS\system32\SnippingTool.exe"
REM runas /user:<your user-name> "C:\WINDOWS\system32\SnippingTool.exe"
REM runas /user:administrator "C:\WINDOWS\system32\SnippingTool.exe"
PAUSE

If you feel like using this script:

1. Change 1st line to: @ECHO OFF

2. Delete any REM'ed lines

3. Delete last line: "PAUSE"

Edited by GokAy
Added how to edit the batch file
Link to comment
Share on other sites

@GokAy you can just use RunAs or RunAsWait to run as a different user.

If you want to use Administrator rights you can just add #RequireAdmin at the top of your script (will cause UAC prompt).  However SnippingTool.exe shouldn't require admin rights to run.

"... when i do Screen shot on my computer and i am trying to save it it says i dont have permission for it."  So does the screenshot appear in the Snipping Tool but you're having issues saving the file?  By default it will use @MyDocumentsDir & "\Pictures", so check that the folder exists and you have access to that folder.

#AutoIt3Wrapper_UseX64=y
Local $sSnippingTool = @SystemDir & "\SnippingTool.exe"
MsgBox(4096, "Save Directory", @MyDocumentsDir & "\Pictures" & @CRLF & "Folder Exists: " & (FileExists(@MyDocumentsDir & "\Pictures") ? "True" : "False"))
If FileExists($sSnippingTool) Then
   Run($sSnippingTool)
Else
   MsgBox(0,'File Error', "The Windows snipping tool was not found")
EndIf

Have you also looked at the _ScreenCapture_... functions (see helpfile for more info).

Link to comment
Share on other sites

; Pasirenka R1



;Paleidzia Snipping Tool.exe, jeigu neranda failo ismeta zinute

#AutoIt3Wrapper_UseX64=y
$sFile = ("C:\windows\system32\SnippingTool.exe")
If FileExists($sFile) Then
   ShellExecute($sFile)
Else
   MsgBox(0,'File Error', "The Windows snipping tool was not found")
EndIf

;Aktvyuoja Snipping Tool

WinActivate ("Snipping Tool")
Sleep(2000)

; Laukia kol aktyvuosis Snipping Tool pasirenka "New" capture

$HWND = WinWaitActive("Snipping Tool", "")
ControlCommand ($HWND, "", "ToolbarWindow321", "SendCommandID", 219)

; Paspaudzia ant RET lango

Sleep(3000)

;Aktvyuoja Snipping Tool

WinActivate ("Snipping Tool")
Sleep(2000)

; Paspaudzia "Save As", Iveda RET pavadinima

Send("{CTRLDOWN}")
sleep(200)
Send("{S}")
sleep(500)
Send("{CTRLUP}")
sleep(500)
Send ("R1")
sleep(500)

; Parenka Folder

ControlClick ("Save As", "", "[CLASSNN:ToolbarWindow324]", "left")
sleep(500)
Send ("Paveiksleliai")
sleep(300)
Send ("{ENTER}")
sleep(300)

; Paspaudzia Save

ControlCommand ("Save As", "", "Button2", "SendCommandID", 1)

I show you full code so basically it opens Snipping tool then choose new snip and then tries to save it also write "Paveiksleliai" (Which means picture) as a folder. When i try to save it gives Error about permission (I add photo). But when i open snipping tool by myself everything works. It is not working when Autoit opens it...

Foto.png

Link to comment
Share on other sites

  • Developers

So this is snipit.exe error and nothing to do with AutoIt3....right?
Are you running under the same user account and did you check the permissions of that folder?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...