hostetterkl
2004-09-10, 02:42 PM
does anyone know how to modify the registry through vb script? I would like to have a program that will add and remove file search paths.
Ed Jobe
2004-09-10, 02:51 PM
Are you sure you mean "vb script" and not a vba macro?
hostetterkl
2004-09-10, 02:54 PM
yes. I want to do this from the desktop and not inside Autocad.
Ed Jobe
2004-09-10, 03:00 PM
I'm sorry, I don't think I can help you without doing some research on msdn. vb requires using the windows api and I don't think you can script api calls. I have only used scripting a little in html. Sorry.
jimmy.bergmark
2004-09-11, 06:15 PM
Here is a sample how to do it:
http://www.jtbworld.com/download\remicontools.zip (http://www.jtbworld.com/download/remicontools.zip)
Here is the VBS documentation
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9
richard.binning
2004-09-14, 02:05 AM
does anyone know how to modify the registry through vb script? I would like to have a program that will add and remove file search paths.
Here is a little one, I just cooked up.
Const c_ADT2004 = "Software\Autodesk\AutoCAD\R16.0\ACAD-204:409\Profiles\Architectural Desktop 2004\General"
Dim fso
Dim d
Dim shell
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive("F:")
If Not d.IsReady then
set oShell = CreateObject("WScript.Shell")
' Edit the following line to match your system
oShell.Run "subst.exe F: L:\F_Drive"
set oShell = Nothing
End If
Set d = fso.GetDrive("W:")
If d.IsReady then
'msgbox "W:\ is available"
VerifySupportPaths d, c_ADT2004
Else
'Check other server
Set d = fso.GetDrive("R:")
If d.IsReady then
'msgbox "W:\ is not connected, but R:\ is ready"
VerifySupportPaths d, c_ADT2004
Else
msgbox "Network disconnected...Ready for Local?"
set oShell = CreateObject("WScript.Shell")
' Edit the following line to match your system
oShell.Run "subst.exe W: L:\W_Drive"
set oShell = Nothing
End If
End If
Function VerifySupportPaths(oDrv, strProduct)
Dim strLetter
strLetter = oDrv.DriveLetter & ":\"
Dim arHives
'constant dictionary
Set arHives = CreateObject("Scripting.Dictionary")
arHives.Add "HKCU", &H80000001
arHives.Add "HKLM", &H80000002
'use WMI to connect to the registry
Dim oReg : Set oReg = GetObject("winmgmts:root\default:StdRegProv")
Dim arValues
Dim arType
Dim oVal
Dim strData
Dim strD2
strRunKey = "Software\Autodesk\AutoCAD\R16.0"
oReg.EnumValues arHives("HKCU"), strRunKey, arValues, arType
oReg.GetStringValue arHives("HKCU"),c_ADT2004,"ACAD",strData
'msgBox strData
If InStr(1, strData, "R:\", 1) > 0 then
'msgbox "Found R:\"
strD2 = Replace(strData, "R:\", "W:\", 1, -1, 1)
Elseif Instr(1, strData, "W:\", 1) > 0 then
'msgbox "No R:\ found"
strD2 = strData
Else
'msgbox "Got a default install eh???"
strD2 = strData
End If
'msgbox strD2
oReg.SetStringValue arHives("HKCU"),c_ADT2004,"ACAD",strD2
'oReg.RegWrite(strName, anyValue [,strType])
'MSGBOX oDrv.DriveLetter & " | " & vbcrlf & strProduct & vbcrlf & vbcrlf & strData
'msgbox strD2
End Function
hostetterkl
2004-09-14, 04:12 PM
thanks, this has been a great help.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.