Automate File Path Configuration

Automate File Path Configuration

Anonymous
Not applicable
338 Views
4 Replies
Message 1 of 5

Automate File Path Configuration

Anonymous
Not applicable
Hi,

Our IT guys in thier wisdom have moved all of the user profiles from the C: drive to the 😧 drive overnight, however they didn't have enough forsight to anticipate that this would screw with AutoCAD's configuration. I have manually mapped about 8 machines in my locality this morning, but we have about 800 staff nationwide...!!! Does anybody know if it is possible to write a script that will automate this process...

This will involve capturing the users login the bit immediately after the C:\Documents and settings\xxXXxx\... so that it can be replaced with D:\Documents and Settings\xxXXxx\...

Can anybody please give me any pointers or script examples, websites etc...

Thanks in anticipation

Ian James
0 Likes
339 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
There are bits and pieces in here that you should find quite useful (this is
from a VBA code module).

(Sorry I don't have the time to clip out the exact parts you're asking
about.........shouldn't be too hard to distinguish, though.)

Dim oAcApp As AcadApplication
Dim oAcPref As AcadPreferences
Dim sSupPath As Variant
Dim vSupPath As Variant
Dim vItm As Variant
Dim bTst As Boolean

Set oAcApp = ThisDrawing.Application
Set oAcPref = oAcApp.Preferences
With oAcPref.Files
'Check/set Support Files path
sSupPath = .SupportPath
vSupPath = Split(sSupPath, ";")
If UCase(vSupPath(0)) <> "\\servername\cadd\SYM\ACAD06" Then
.SupportPath = "\\servername\cadd\SYM\ACAD06;G:\CECSYM;" & sSupPath
End If
.PrinterConfigPath = "c:\Acad2006\Plotters"
.PrinterDescPath = "c:\Acad2006\Plotters\PMP Files"
.PrinterStyleSheetPath = "\\servername\cadd\SYM\Plot Styles"
.TemplateDwgPath = "\\servername\cadd\YSM\Templates"
End With
With oAcPref
.OpenSave.FullCRCValidation = True
.System.LoadAcadLspInAllDocuments = True
.OpenSave.IncrementalSavePercent = 0
End With
Set oAcPref = Nothing: Set oAcApp = Nothing

Call CheckLocalAcadSupportFiles

Sub CheckLocalAcadSupportFiles()
Dim sAcadVer As String
Dim sAppData As String
Dim vAcadPaths() As String 'List of POSSIBLE Acad paths
Dim iCnt As Integer
Dim sFile As Variant
Dim oFso As FileSystemObject, oFile As File
sAcadVer = Application.Version
sAppData = Environ("appdata") 'Returns c:\Documents and
Settings\username\Application Data
ReDim vAcadPaths(1)
vAcadPaths(0) = "\Autodesk\Autodesk Land Desktop 2006\R16.2\enu\Support"
'Land & Map
vAcadPaths(1) = "\Autodesk\C3D 2006\enu\Support"
'Civil 3D
For iCnt = 0 To UBound(vAcadPaths)
sFile = Dir(sAppData & vAcadPaths(iCnt) & "\acad.pat")
If UCase(sFile) = "ACAD.PAT" Then
Set oFso = New FileSystemObject
Set oFile = oFso.GetFile(sAppData & vAcadPaths(iCnt) & "\acad.pat")
'Debug.Print " size of acad.pat: " & oFile.Size
'Original size (2006): 14812 CEC size of acad.pat: 287600
If oFile.Size < 15000 Then
oFso.CopyFile "\\servername\cadd\cecsym\Acad06\acad.pat.---",
sAppData & vAcadPaths(iCnt) & "\acad.pat", True
oFso.CopyFile "\\servername\cadd\cecsym\Acad06\acad.slb.---",
sAppData & vAcadPaths(iCnt) & "\acad.slb", True
End If
Set oFile = Nothing
Set oFso = Nothing
End If
Next
End Sub



wrote in message news:5372353@discussion.autodesk.com...
Hi,

Our IT guys in thier wisdom have moved all of the user profiles from the C:
drive to the 😧 drive overnight, however they didn't have enough forsight to
anticipate that this would screw with AutoCAD's configuration. I have
manually mapped about 8 machines in my locality this morning, but we have
about 800 staff nationwide...!!! Does anybody know if it is possible to
write a script that will automate this process...

This will involve capturing the users login the bit immediately after the
C:\Documents and settings\xxXXxx\... so that it can be replaced with
D:\Documents and Settings\xxXXxx\...

Can anybody please give me any pointers or script examples, websites etc...

Thanks in anticipation

Ian James
0 Likes
Message 3 of 5

Anonymous
Not applicable
Tom,

Thanks very much... this looks great. Just what the doctor ordered.

I'll have a play with it today and hopefully that will solve the problem.

Regards

Ian
0 Likes
Message 4 of 5

Anonymous
Not applicable
This may be all you need
[code]
Sub SupportPathing()
Dim Preferences As AcadPreferences
Dim Pref As String
Dim SupportPath As String
Dim sNewSupportPath As String
Dim sFind As String, sReplace As String

Set Preferences = ThisDrawing.Application.Preferences
SupportPath = Preferences.Files.SupportPath
Debug.Print SupportPath
sFind = "C:\Documents and Settings"
sReplace = "D:\Documents and Settings"
sNewSupportPath = Replace(SupportPath, sFind, sReplace)
Debug.Print sNewSupportPath
Preferences.Files.SupportPath = sNewSupportPath
End Sub
[/code]
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thanks,

I just finished coding the macro... not as elegant as yours a bit manual, but it does the job.

I like your use of Replace... not done that before...

But then again not programmed anything for about 6 years

Thanks to All for your help

Ian James
BDP Architects (UK)
0 Likes