Refresh Registry [Windows]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Refresh Registry [Windows]

Post by RASHAD »

Hi
Example : After auto arrange Icons
#1 : Using VBscript

Code: Select all

RunProgram("REG"," ADD "+Chr(34)+"HKCU\SOFTWARE\Microsoft\Windows\Shell\Bags\1\Desktop"+Chr(34)+" /V FFLAGS /T REG_DWORD /D 1075839524 /F","")
OpenFile(0,GetHomeDirectory()+"rashad.vbs")
  Restore StringData
  For i = 1 To 10
    Read.s MyData$
    WriteStringN(0,MyData$)
  Next
CloseFile(0)
RunProgram(GetHomeDirectory()+"rashad.vbs","","",#PB_Program_Hide)
Delay(50)
;DeleteFile(GetHomeDirectory()+"rashad.vbs")
  
DataSection    
  StringData:
    Data.s "Function RefreshExplorer()"
    Data.s "dim strComputer, objWMIService, colProcess, objProcess"
    Data.s "strComputer = "+Chr(34)+"."+Chr(34)
    Data.s "Set objWMIService = GetObject("+Chr(34)+"winmgmts:"+Chr(34)+" & "+Chr(34)+"{impersonationLevel=impersonate}!\\"+Chr(34)+" & strComputer & "+Chr(34)+"\root\cimv2"+Chr(34)+")"
    Data.s "Set colProcess = objWMIService.ExecQuery ("+Chr(34)+"Select * from Win32_Process Where Name = 'explorer.exe'"+Chr(34)+")"
    Data.s "For Each objProcess in colProcess"
    Data.s "objProcess.Terminate()"
    Data.s "Next"
    Data.s "End Function"
    Data.s "Call RefreshExplorer"
EndDataSection

#2 : Using PowerShell

Code: Select all

RunProgram("REG"," ADD "+Chr(34)+"HKCU\SOFTWARE\Microsoft\Windows\Shell\Bags\1\Desktop"+Chr(34)+" /V FFLAGS /T REG_DWORD /D 1075839524 /F","")
RunProgram("powershell.exe","stop-process -name explorer -force","",#PB_Program_Hide)
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Refresh Registry [Windows]

Post by Kwai chang caine »

I don't know if that works, because i not have something to change, needed to refresh BDR for the moment :oops:
But i have often search this style of code in the past time :|
In all case, thanks for sharing MASTER this usefull code 8)
ImageThe happiness is a road...
Not a destination
Post Reply