Sign in to follow this  
Followers 0
DietCoke

Mapping check & Notify issue

5 posts in this topic

Hi,

I'm trying to build out a script (based in part by different portions of code I've used here and a bit on my own) that will check the following:

If drive X is being used;

If drive X is being used, email to an email address with notification

If drive X is not being used, map the drive to a predefined path

I've started with this code:

$Idrive = DriveMapGet ("x:")
if $idrive == "" then
   DriveMapAdd("X:", "\\dept\pub$", 1)
   Else
#include <INet.au3> 
$s_SmtpServer = "SMTP Server" 
$s_FromName = "Mapping issue notifier" 
$s_FromAddress = "From address" 
$s_ToAddress = "To address"
$s_Subject = "Subject line" 
Dim $as_Body[1] 
$as_Body[0] = "PC contains mapped drive issues for username: " & @USERNAME " from PC name: " & @ComputerName
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body,"","-1") 
Endif

But when I do, I get the error:

Line 212 (File""):

Error: "If" statement has no matching EndIf statement.

This has to be a syntax issue, but I'm not seeing anything wrong. I've worked on this for a couple of hours using different approaches and figured it was time for outside help. Does anyone have any suggestions?

Thanks for any help or pointers!

Share this post


Link to post
Share on other sites



The problem is where you have placed the include statement

#include <INet.au3>

This should be near the top of your script and certainly not within a function or in the middle of other of code


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you - that makes sense, I appreciate the tip! However, after putting the include up at the top I'm now getting the error:

Line 3441 (File "C:\AutoIt_Code\map_src.exe"):

Error: Error in expression.

Any ideas? I wish the errors truly related to lines. Thank god I don't have 3441 lines of code for this item.

Edited by DietCoke

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

error on

$as_Body[0] = "PC contains mapped drive issues for username: " & @USERNAME " from PC name: " & @ComputerName

probably need to change to

$as_Body[0] = "PC contains mapped drive issues for username: " & @USERNAME & " from PC name: " & @ComputerName

Edit:

next time test it like script (dont test it compiled) it will write where error is (line number) in scite

(hit F5 when your in scite editor)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

Thank you so much! Wow - one character and one line movement between me and success on this one... great info also in hitting F5 before a compile. Here's the finalized code, tested here successfully:

#include <INet.au3> 
$Idrive = DriveMapGet ("x:")
if $idrive == "" then
   ;DriveMapAdd("X:", "\\server\folder", 1)
   Else
$s_SmtpServer = "SMTP Server" 
$s_FromName = "From Name" 
$s_FromAddress = "Sender email address" 
$s_ToAddress = "Recipient email address"
$s_Subject = "Customer has pre-existing X drive" 
Dim $as_Body[1] 
$as_Body[0] = "PC contains mapped drive issue for username: " & @USERNAME & " from PC name: " & @ComputerName
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body,"","-1") 
Endif

Thanks to Bowmore and bogQ - you guys really helped today!

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