Login script der mounter truecrypt volume
Hej!For at få bedre sikkerhed på min pc har jeg besluttet mig for at flytte alle mine dokumenter indbefattet skrivebordet til en virtuel harddisk, der ligger i en krypteret fil vha. TrueCrypt (http://www.truecrypt.org/)
Jeg har i nogen til bakset med et "login"-script der lukker explorer.exe, kører TrueCrypt commandline, så der kommer en password-dialog frem og så kører i uendelig løkke indtil disken (X:\) er mounted.
Problemet er nu at explorer hele tiden åbner igen, og ikke venter til x:\ er mounted.
Kode:
option explicit
Dim objFso, objWMIService, objStartup, objConfig, objProcess, colProcess, strComputer, intProcessID, intProcessID1
Set objFso= Wscript.CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'explorer.exe'")
strComputer = "."
'kill explorer.exe
For Each objProcess in colProcess
objProcess.Terminate()
Next
'open TrueCrypt window
objProcess.Create "c:\Program Files\TrueCrypt\TrueCrypt /q /v c:\tc", Null, objConfig, intProcessID
'wait for volume to be mounted
set objFso= Wscript.CreateObject("Scripting.FileSystemObject")
Do Until objFso.FolderExists("X:\")
WScript.Sleep(50)
Loop
'open explorer again
Const ABOVE_NORMAL = 32768
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.PriorityClass = ABOVE_NORMAL
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
objProcess.Create "explorer.exe", Null, objConfig, intProcessID
(Naturligvis skal explorer starte med HIGH proirity og ikke ABOVE_NORMAL, men kunne ikke finde koden for det.)
Problemet var så at explorer åbnede inden x:\ var mounted.
(Hvilket naturligvis ikke kan accepteres da desktoppen ligger på X:\)
Jeg prøvede så denne version:
(logon.vbs)
option explicit
Dim objFso, objWMIService, objStartup, objConfig, objProcess, colProcess, strComputer, intProcessID, intProcessID1
Set objFso= Wscript.CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'explorer.exe'")
strComputer = "."
'kill explorer.exe
Const ABOVE_NORMAL = 32768
strComputer = "."
objConfig.PriorityClass = ABOVE_NORMAL
objProcess.Create "killexplorer.vbs", Null, objConfig, intProcessID1
wscript.echo(intProcessID1)
(exitExplorer.vbs)
option explicit
Dim objFso, objWMIService, objStartup, objConfig, objProcess, colProcess, strComputer, intProcessID
do while true
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'explorer.exe'")
'kill explorer.exe
For Each objProcess in colProcess
objProcess.Terminate()
Next
loop
Men det virkede heller ikke, intProcessID blev bare null.
Nogen ideer?