** Edit - Perhaps it would be better to call that when the DocumentCreated Event is raised instead.
I need to get a notification about the drawing opening, and to close this document at once, if it is necessary for me. How can I do it?
P.S. In an ideal I want to have opportunity to cancel drawing opening, instead of to close after opening.
Regards, Andrey.
Can you tell why you need this?My users are use the AutoCAD 2009. They often infect the network and local computers through acad*.lsp, or acad*.fas. This problem is not only for my company. I blocked automatic loading of files acad*.lsp, and acad*.fas (through .NET). But I want not only to block danger, but also to remove that already extended...
Is it the virus mentioned here CAD Virus (http://www.theswamp.org/index.php?topic=37419.0)?Are exist many types of this infection. I didn't compare them. One of types of this virus writes itself into all directories of drawings, and into all directories of "support files search path". it also writes itself into all lsp and mnl files.
Other links from link above.Our company used the Kaspersky (http://www.kaspersky.com) antivirus. I have sent the mail about this virus them. But often it not help, and antivirus corrupts the autocad files (other lsp and mnl files).
McAfee info and description (http://www.mcafee.com/threat-intelligence/malware/default.aspx?id=100887)
Autodesk solution for removal (http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=13717811&linkID=9240617)
I'm not knowledgeable enough to suggest anything other than an asynchronous call to Close Command via IExtensionApplication.Initialize()The Initialize method doesn't suit for this task.Code - C#: [Select]
public void Initialize() { Document doc = acApp.DocumentManager.MdiActiveDocument; if (doc.Name.Contains("TheDawgNameYouDontWantOpened")) doc.SendStringToExecute("Close\n", false, false, true); }
** Edit - Perhaps it would be better to call that when the DocumentCreated Event is raised instead.I already tried this method earlier, but received Fatal Error:
I already tried this method earlier too, but received Fatal Error again:Code - C#: [Select]
public void CloseDwgIf(Document doc) { if (doc.Name.Contains("TheDawgNameYouDontWantOpened")) doc.SendStringToExecute("Close\n", false, false, true); }
I'm not knowledgeable enough to suggest anything other than an asynchronous call to Close Command via IExtensionApplication.Initialize()The Initialize method doesn't suit for this task.Code - C#: [Select]
public void Initialize() { Document doc = acApp.DocumentManager.MdiActiveDocument; if (doc.Name.Contains("TheDawgNameYouDontWantOpened")) doc.SendStringToExecute("Close\n", false, false, true); } ** Edit - Perhaps it would be better to call that when the DocumentCreated Event is raised instead.I already tried this method earlier, but received Fatal Error:Code - C#: [Select]And...
static void docMng_DocumentCreated(object sender, App.DocumentCollectionEventArgs e) { if (e.Document != null) e.Document.CloseAndDiscard(); } Quote from: BlackBoxI already tried this method earlier too, but received Fatal Error again:Code - C#: [Select]
public void CloseDwgIf(Document doc) { if (doc.Name.Contains("TheDawgNameYouDontWantOpened")) doc.SendStringToExecute("Close\n", false, false, true); } Code - C#: [Select]BlackBox, try the your code before advising, please. :-(
static void docMng_DocumentCreated(object sender, App.DocumentCollectionEventArgs e) { if (e.Document != null) e.Document.SendStringToExecute("Close\n", false, false, true); }
there is something wrong with your code, my friend.I have created the new Visual Studio 2012 project for AutoCAD 2009 SP3 x64 Enu.
Not sure what version you're currently using, but you might consider AutoLISP and VBA Security Controls in AutoCAD 2013 SP1.I know this info, and I think it was added by my ADN Case 06921325. My users use the AutoCAD 2009 SP3 Enu.
rather than attempting to 'veto'...By means of the prohibition I try to force users to be more responsible.
Once the malicious code has soiled your own .LSP, and .MNL files though, the only alternative is to be 'highly reactive' I'm afraid . I sure hope you have good, nightly backups to restore from.It is not problem. In the some server's directory are located all lsp, fas, and mnl files as samples. This directory are read only for all users. My "antivirus" use this files for the quick recovery of local files.
Quote from: BlackBoxthere is something wrong with your code, my friend.I have created the new Visual Studio 2012 project for AutoCAD 2009 SP3 x64 Enu.
I copied your last modified code into project and run it. In your code I replaced the "TheDawgNameYouDontWantOpened" on the "Field.dwg". When I try to open the "Field.dwg" I get the Fatal Error.
Then I changed the project for AutoCAD 2013 SP1.1 x64 Enu. When I try to open the "Field.dwg", I don't get the Fatal Error, but the "Field.dwg" was opened.
Both results are wrong.