Sign in to follow this  
Followers 0
mholder

(New to autoit) Save file to specific network drive

9 posts in this topic

#1 ·  Posted

Hello all,

Probably asked and answered, but I couldn't find it. My goal is to create a script(or set of scripts as the case may be) so my users can run some daily computer maintenance tasks when they leave the office for the night. I'm working my way through the code, and I see the potential. But my first hurdle is:

I have a script that successfully runs a quick scan on windows defender, I then have it set up to take a screenshot of the results. My idea is to have those results save to a specific folder on a shared network drive, but I can't find in the help file which command is best.

 

Current script:

#RequireAdmin
send( '#d')
run("c:\program files\windows defender\msascui.exe")
winwait( 'Windows Defender')
controlclick( 'Windows Defender', '', 'ATL:BUTTON2')
send( 'u')
sleep(60000)
controlclick( 'Windows Defender', '', 'ATL:BUTTON1')
controlclick( 'Windows Defender', '', 'ATL:BUTTON6')
controlclick( 'Windows Defender', '', 'ATL:BUTTON9')
sleep(120000)
send( '^{printscreen}')
send( '#r')
send( 'pbrush')
send( '{enter}')
WinWait('Untitled - Paint')
WinActivate('Untitled - Paint')
send('^v')
sleep(1000)
send('{f12}')
sleep(1000)
send('wdscan')
sleep(1000)
send('{enter}')

 

Can anyone assist?

Thanks,

Michael

Share this post


Link to post
Share on other sites



#2 ·  Posted

#include <ScreenCapture.au3>

Local $networkSharePath = "\\server\images\scan.jpg"
_ScreenCapture_Capture ( $networkSharePath, 0, 0)

This will automatically save a screenshot of the entire desktop to the network drive, just replace the path with the path to the folder you want on your network. If you want the image to be only Windows Defender, just change the parameters of the screen capture. The parameters can be found by clicking on the function in the code of this post.


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#3 ·  Posted

1 hour ago, anthonyjr2 said:
#include <ScreenCapture.au3>

Local $networkSharePath = "\\server\images\scan.jpg"
_ScreenCapture_Capture ( $networkSharePath, 0, 0)

This will automatically save a screenshot of the entire desktop to the network drive, just replace the path with the path to the folder you want on your network. If you want the image to be only Windows Defender, just change the parameters of the screen capture. The parameters can be found by clicking on the function in the code of this post.

Thank you! exploring as we speak. 

Share this post


Link to post
Share on other sites

#4 ·  Posted

Quote

 

Hey,

I think your path might be wrong, you need to include the file name in it as well. Try this and let me know what the return code is:

#include <ScreenCapture.au3>
local $networksharepath = "\\"IP ADDRESS OF SERVER"\N:\Windows Defender Scans\image.png"
send( '#d')
run("c:\program files\windows defender\msascui.exe")
winwait( 'Windows Defender')
controlclick( 'Windows Defender', '', 'ATL:BUTTON2')
send( 'u')
sleep(1000)
controlclick( 'Windows Defender', '', 'ATL:BUTTON1')
controlclick( 'Windows Defender', '', 'ATL:BUTTON6')
controlclick( 'Windows Defender', '', 'ATL:BUTTON9')
sleep(1000)
_ScreenCapture_Capture( $networksharepath , 0, 0)
If @error Then
    MsgBox(0, "Error", "Error code: " & @error)
EndIf

Alternatively if that doesn't fix anything, try replacing the capture lines with this:

$hBmp = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage($networkSharePath, $hBmp)
If @error Then
    MsgBox(0, "Error", "Error code: " & @error)
EndIf

and also maybe capture the error message.

I also request that you continue this conversation in the thread you posted, as asking for help through PMs is generally frowned upon unless the discussion topic needs to be private. It'll help people with your problem in the future!

 

-Anthony

 

Just posting my PM to you here so we have some record of things.


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#5 ·  Posted

1 hour ago, anthonyjr2 said:

Just posting my PM to you here so we have some record of things.

#include <ScreenCapture.au3>
local $networksharepath = "\\N:\Windows Defender Scans\wdscan.png"
send( '#d')
run("c:\program files\windows defender\msascui.exe")
winwait( 'Windows Defender')
controlclick( 'Windows Defender', '', 'ATL:BUTTON2')
send( 'u')
sleep(1000)
controlclick( 'Windows Defender', '', 'ATL:BUTTON1')
controlclick( 'Windows Defender', '', 'ATL:BUTTON6')
controlclick( 'Windows Defender', '', 'ATL:BUTTON9')
sleep(1000)
$hBmp = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage($networkSharePath, $hBmp)
If @error Then
    MsgBox(0, "Error", "Error code: " & @error)
EndIf
_ScreenCapture_Capture( $networksharepath , 0, 0)

 

Here's what I have now and I am receiving error code 1

Share this post


Link to post
Share on other sites

#6 ·  Posted

I am not sure what error 1 means because it isn't listed anywhere. Are you sure it isnt -1?

Regardless, I used the following code and it worked perfectly on my machine:

#include <ScreenCapture.au3>
local $networksharepath = "\\STATION108\Users\username\Documents\images\image.png"

sleep(2000)
_ScreenCapture_Capture( $networksharepath , 0, 0)
If @error Then
    MsgBox(0, "Error", "Error code: " & @error)
EndIf

This leads me to believe that it is an error with your path. Are you sure that it is a valid path name? The way I always get a file path is to go to the folder in Windows Explorer, then double click the address bar and copy the path directly from there. Try that and let me know how it goes. I'm leaving the office now so I won't be able to reply until tomorrow morning.


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites

#7 ·  Posted

I tried this also the " error code 1" Showed only when the program can't save screenshot to selected path like @anthonyjr2 said ,  you must check if your can create new file or new folder in " "\\N:\Windows Defender Scans\"

Share this post


Link to post
Share on other sites

#8 ·  Posted

1 hour ago, anthonyjr2 said:

I am not sure what error 1 means because it isn't listed anywhere. Are you sure it isnt -1?

Regardless, I used the following code and it worked perfectly on my machine:

#include <ScreenCapture.au3>
local $networksharepath = "\\STATION108\Users\username\Documents\images\image.png"

sleep(2000)
_ScreenCapture_Capture( $networksharepath , 0, 0)
If @error Then
    MsgBox(0, "Error", "Error code: " & @error)
EndIf

This leads me to believe that it is an error with your path. Are you sure that it is a valid path name? The way I always get a file path is to go to the folder in Windows Explorer, then double click the address bar and copy the path directly from there. Try that and let me know how it goes. I'm leaving the office now so I won't be able to reply until tomorrow morning.

Copying directly from windows explorer worked! Thank you!

Share this post


Link to post
Share on other sites

#9 ·  Posted

Glad I could help :)


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
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
Sign in to follow this  
Followers 0