refresh user profile

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 2 Followers

Not Ranked
7 Posts
Chris Ngu posted on 05-12-2012 2:24 AM

I found this vbs script to refresh the current user profile so you can see the change immediately. what would be the powershell equivalent

Set oShell = CreateObject("WScript.Shell")
Set oSHApp = CreateObject("Shell.Application")
Set oFSO = CreateObject("Scripting.FileSystemObject")

'Set Wallpaper to Path Below
sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = "C:\WINDOWS\DOMXP.bmp"

' Update Wallpaper in registry
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
wscript.sleep 3000

'Refresh Screen
oSHApp.ControlPanelItem cstr("desk.cpl")
' alt. oShell.Run "control desk.cpl"

Do Until oShell.AppActivate ("Display Properties")
oShell.SendKeys "{DOWN}{UP}{TAB 3}~"

'Minimise all Windows.

All Replies

Top 10 Contributor
640 Posts

I'm not able to rewrite the entire script for you, but here's an example.

$shell = new-object -com 'WScript.Shell'
$'control desk.cpl')

That's how to create a COM object and run one of its methods. 

Not Ranked
7 Posts

The wallpaper was just an example. I want to be able to refresh the user's running profile so that changes made via the registry, such as with the Environment Variable PATH, can be applied to the user's running profile without logging off and back on.
So that it can be used for scripted program installations which will make Environment Variable changes via registry key value additions within HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment.

Idk if that makes a little more sense

Top 10 Contributor
640 Posts

I understand... I'm just saying that, in a free Q&A forum, I'm not really able to invest the time to rewrite your entire script for you. Instead, I provided you with an example of the PowerShell syntax, using a specific portion of your script as an example.

You should be able to take that syntax example and apply it to the rest of your script yourself. Everything in that VBScript you pasted can be converted to the PowerShell syntax I showed you.

Not Ranked
7 Posts

Thank you

Page 1 of 1 (5 items) | RSS
Copyright 2012 All rights reserved.