[WMI] 비주얼 스튜디오 2005 단축키 설정 불러오기 by TTF
비주얼 스튜디오 환경설정 Setting 파일을 이용해서
"단축키 설정"과 "프로젝트 디렉터리 설정"을 쉽게 불러오는데 성공하였다.

하지만 비주얼 스튜디오 설치 과정에서 괴로운 작업이 한가지 더 있다.
바로 환경변수에 폴더 경로를 추가하는 작업.

그렇게 힘들진 않지만 윈도우 단축키와 마우스 컨트롤이 단련되어 있지 않은
"특수한" 프로그래머들은 이런 것 하나를 추가하는데에도 고통을 느낀다.(으악~~)

자자 아래와 같이 한방에 등록해 주는 WMI 스크립트!
이제 비주얼 스튜디오 환경변수 설정할 때 약간(?) 도움을 받을 수 있다. ㅎㅎㅎ

"Env_Setting.vbs" 파일만 클릭해 주면,
현재 "Env_Setting.vbs"가 있는 위치의 폴더 경로를 얻어와서,
그동안 등록하기 불편했던 환경 설정 변수들을 모두 등록 해준다.



Option Explicit
  
Dim strComputer : strComputer = "."
  
' 기본 Object 가져오기
Dim Shell : Set Shell = WScript.CreateObject("WScript.Shell")
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Dim WshEnv : Set WshEnv = Shell.Environment("Process")
Dim ProgramDir : ProgramDir = WshEnv("ProgramFiles")
Dim Reg : Set Reg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Dim WMIService : Set WMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  
'CMD 윈도우 98에서도 적용 가능하게 COMSPEC으로 가져온다.
Dim COMSPEC : COMSPEC = Shell.ExpandEnvironmentStrings("%comspec%")
  
  
'현재 세팅 파일 경로 구하기
Dim strSetupFile : strSetupFile = "Env_Setting.vbs"
  
'Main 함수 실행 후 종료
MainFunction
Wscript.quit
  
'Main 함수
Sub MainFunction
' 세팅 파일 절대 경로 구하기
  Dim strParentFolderPath
  GetParentFolderPath strSetupFile, strParentFolderPath
  
' 환경 변수 레지스트리 설정
  Const HKEY_CURRENT_USER = &H80000001
  Const HKEY_LOCAL_MACHINE = &H80000002
  
  Dim strKeyPath, strValueName, strValue
  
  '일단 등록하고 아래에서 바로 사용할 수 있도록 Refresh 하자
  strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
  strValueName = "TTF_Base"
  strValue = strParentFolderPath
  Reg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  
  strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
  strValueName = "TTF_Base_Header"
  strValue = "%TTF_Base%\include\Header"
  Reg.SetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  
  strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
  strValueName = "TTF_Base_Lib"
  strValue = "%TTF_Base%\Include\Library"
  Reg.SetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  
  strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
  strValueName = "TTF_Base_UnitTest"
  strValue = "%TTF_Base%\UnitTest++\src"
  Reg.SetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
  
  
'환경 변수 새로고침(바로 사용 가능하도록 Refresh)
  Dim colItems : Set colItems = WMIService.ExecQuery ("Select * from Win32_Environment WHERE SystemVariable = True")
  
  Dim objItem
  For Each objItem in colItems
         objItem.Put_
  Next
End Sub
  
Sub GetParentFolderPath(strFileName, strFileFullPath)
  Dim objFile
  Set objFile = FSO.GetFile( strFileName )
  strFileFullPath = FSO.GetParentFolderName(objFile)
End Sub
2008/07/10 01:40 2008/07/10 01:40

글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다

덧글을 달아 주세요