Page 1 of 1 1
Topic Options
#173982 - 2007-02-16 05:27 PM set command
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
I am writing a script in Kixtart that will give the user the option to have his my documents redirected to pass while they are logged in. The script makes the necessary changes to the registry but the changes are not reflected on the My Doc folder until the machine is restarted. I need explorer to reread the registry without a restart, I think this can be done with a "set"command.
Top
#173983 - 2007-02-16 05:49 PM Re: set command [Re: cop2999]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Maybe a Desktop Refresh would do the trick. Allan had a really clever way of doing this, but damn if I can find it. Something to do with sending F5 using SendKeys ... Anyone ?

-Shawn

[edit] - was doing some reading ... looks like refreshing the desktop won't work for what you want ... there was talk about killing explorer.exe though - thats kinda scary.

Top
#173984 - 2007-02-16 06:10 PM Re: set command [Re: Shawn]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Shawn... is this what you are looking for?
RefreshDesktop() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=164087&page=3#Post164087

...but you are right... I think the only way that consistently works (anyone has found) is to kill explorer.
_________________________
(... better days ahead)

Top
#173986 - 2007-02-16 06:26 PM Re: set command [Re: Allen]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Thats it! Yeah

The way we "do this" (something similar anyways) is to run the logon script in "synchronous mode". That is to say, before the desktop is built - we do much redirecting of standard folders and it works well in this mode.

Of course, there is a downside to running sync example, the login script has to finish before the user gets control - and it might appear that your login process runs longer - but thats your call if you go there.

Top
#173987 - 2007-02-16 06:32 PM Re: set command [Re: Shawn]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
This is the other thing to try... I think Jens wrapped this up in a UDF too...

 Code:
 RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True 
_________________________
(... better days ahead)

Top
#173988 - 2007-02-16 06:34 PM Re: set command [Re: Allen]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Definitely give that one a try. Looks very promising.
Top
#173989 - 2007-02-16 06:35 PM Re: set command [Re: Shawn]
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
Thanks I'll give it a try.
Top
#173992 - 2007-02-16 07:28 PM Re: set command [Re: cop2999]
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
I get a error: unknown command [rundll32.exe] when I try this
Top
#173993 - 2007-02-16 07:39 PM Re: set command [Re: cop2999]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
um... you need to wrap it in a SHELL or RUN.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#173994 - 2007-02-16 08:20 PM Re: set command [Re: Les]
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
I know this will work because I dug down and executed the file and it worked. Here is my line of code, I dont get an error but I also dont get any results.

Shell "RunDll32.exe user32.dll,UpdatePerUserSystemParameters ,1 ,True"

Top
#174002 - 2007-02-17 05:10 AM Re: set command [Re: cop2999]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And here's the UDF: UpdateUserParameters()
_________________________
There are two types of vessels, submarines and targets.

Top
#174036 - 2007-02-19 03:12 PM Re: set command [Re: Sealeopard]
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
It is still not working, I know it should but is does not. Here is my whole script if anyone can help thanks.

$System = CreateObject("Kixtart.System")
;
;KD START
;
$Form = $System.Form()
;
$Form.BackColor = 212,208,200
$Form.Height = 337
$Form.Left = -16
$Form.Text = "User Setup 1.0"
$Form.Top = 13
$Form.Width = 541
$GroupBox1 = $Form.Controls.GroupBox()
$GroupBox1.BackColor = 212,208,200
$GroupBox1.Height = 183
$GroupBox1.Left = 60
$GroupBox1.Text = "Home Folder -- location for My Documents"
$GroupBox1.Top = 45
$GroupBox1.Width = 423
$Button1 = $GroupBox1.Controls.Button()
$Button1.Height = 23
$Button1.Left = 330
$Button1.Text = "Map Now"
$Button1.Top = 90
$Button1.Width = 75
$Button1.OnClick = "Redirect() "
$Label1 = $GroupBox1.Controls.Label()
$Label1.BackColor = 212,208,200
$Label1.Enabled = "False"
$Label1.Height = 24
$Label1.Left = 15
$Label1.Text = "Pass (X:) -- central Windows file service (win.pass.psu.edu)"
$Label1.Top = 90
$Label1.Width = 307
$Button2 = $Form.Controls.Button()
$Button2.Cancel = "True"
$Button2.FontBold = "True"
$Button2.FontUnderline = "True"
$Button2.Height = 23
$Button2.Left = 60
$Button2.Text = "Cancel"
$Button2.Top = 270
$Button2.Width = 75
$Button2.OnClick = "quit()"
$Button3 = $Form.Controls.Button()
$Button3.FontBold = "True"
$Button3.FontUnderline = "True"
$Button3.Height = 23
$Button3.Left = 240
$Button3.Text = "Help"
$Button3.Top = 270
$Button3.Width = 75
$Button4 = $Form.Controls.Button()
$Button4.FontBold = "True"
$Button4.FontUnderline = "True"
$Button4.Height = 23
$Button4.Left = 405
$Button4.Text = "OK"
$Button4.Top = 270
$Button4.Width = 75
$Button4.OnClick = "UpdateUserParameters()"
;
;KD END
;
$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1
;==============================================
;
Function Redirect
WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Personal","y:\My Documents","REG_EXPAND_SZ") WriteValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","y:\My Documents","REG_EXPAND_SZ")
EndFunction
;
Function UpdateUserParameters()
Shell 'RunDll32.exe user32.dll,UpdatePerUserSystemParameters'
Exit @ERROR
EndFunction

Top
#174037 - 2007-02-19 03:40 PM Re: set command [Re: cop2999]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Hi cop2999,

You should place your code between code tags, here is a link to help you out.
The Post/Reply Formatting Box And How to Use it.

Try this and let us know what you get for an error:
 Code:
;
;KD START
;

$System = CreateObject("Kixtart.System")
If Not $System
	$nul= MessageBox("KiXforms Not Initiated."+@CRLF+
	"Please verify KiXforms is installed."+@CRLF+
	"This Script Will Now Close.","Error",16)
	Quit()
EndIf

$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.Height = 337
$Form.Left = -16
$Form.Text = "User Setup 1.0"
$Form.Top = 13
$Form.Width = 541

$GroupBox1 = $Form.Controls.GroupBox()
$GroupBox1.BackColor = 212,208,200
$GroupBox1.Height = 183
$GroupBox1.Left = 60
$GroupBox1.Text = "Home Folder -- location for My Documents"
$GroupBox1.Top = 45
$GroupBox1.Width = 423

$Button1 = $GroupBox1.Controls.Button()
$Button1.Height = 23
$Button1.Left = 330
$Button1.Text = "Map Now"
$Button1.Top = 90
$Button1.Width = 75
$Button1.OnClick = "Redirect() "

$Label1 = $GroupBox1.Controls.Label()
$Label1.BackColor = 212,208,200
$Label1.Enabled = "False"
$Label1.Height = 24
$Label1.Left = 15
$Label1.Text = "Pass (X:) -- central Windows file service (win.pass.psu.edu)"
$Label1.Top = 90
$Label1.Width = 307

$Button2 = $Form.Controls.Button()
$Button2.Cancel = "True"
$Button2.FontBold = "True"
$Button2.FontUnderline = "True"
$Button2.Height = 23
$Button2.Left = 60
$Button2.Text = "Cancel"
$Button2.Top = 270
$Button2.Width = 75
$Button2.OnClick = "quit()"

$Button3 = $Form.Controls.Button()
$Button3.FontBold = "True"
$Button3.FontUnderline = "True"
$Button3.Height = 23
$Button3.Left = 240
$Button3.Text = "Help"
$Button3.Top = 270
$Button3.Width = 75

$Button4 = $Form.Controls.Button()
$Button4.FontBold = "True"
$Button4.FontUnderline = "True"
$Button4.Height = 23
$Button4.Left = 405
$Button4.Text = "OK"
$Button4.Top = 270
$Button4.Width = 75
$Button4.OnClick = "UpdateUserParameters()"

;
;KD END
;
$Form.Show
While $Form.Visible
	$=Execute($Form.DoEvents())
Loop
Exit 1
;==============================================
;
Function Redirect()
	$nul = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders","Personal","y:\My Documents","REG_EXPAND_SZ")
	If Not(@ERROR = 0)
		? 'First WriteValue had an error# '+@ERROR
	EndIf
	$nul = WriteValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders","Personal","y:\My Documents","REG_EXPAND_SZ") 
	If Not(@ERROR = 0)
		? 'Second WriteValue had an error# '+@ERROR
	EndIf
EndFunction
;
Function UpdateUserParameters()
	Shell 'RunDll32.exe user32.dll,UpdatePerUserSystemParameters'
	Exit @ERROR
EndFunction
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174038 - 2007-02-19 03:43 PM Re: set command [Re: Benny69]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Setting it by GPO would have immediate effect. No restart or whatever needed.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#174040 - 2007-02-19 03:54 PM Re: set command [Re: cop2999]
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
I am curently using gp to do this but for some reasons I get a real slow logon time, like 3 to 5 min. This is my work around.


Anyway the shell function is not working for me, everything else works.

Top
#174041 - 2007-02-19 04:19 PM Re: set command [Re: cop2999]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
did you get any errors when you ran the code i modified for you?
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174042 - 2007-02-19 04:42 PM Re: set command [Re: cop2999]
cop2999 Offline
Fresh Scripter

Registered: 2007-02-16
Posts: 8
Benny69

I did not get any errors, the reg entries are changed but the refresh does not happen.

Top
#174085 - 2007-02-20 07:53 PM Re: set command [Re: cop2999]
ChrisRogers Offline
Lurker

Registered: 2007-02-19
Posts: 1
Its because windows XP im guessing your using windows XP does not Start the network up right away EG. windows 2000 Starts the network engine UP then shows the login box Where windows XP Starts the login box and allows users to login while the network engine is starting u, if you goto local computer GP, and goto System Settings >> Admin Temp >> Logon the bottom Value called Wait for network to initalise first Set that to Enable, this should put your system a tony bit slower showing the login box
but your network login should fly through.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 836 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.195 seconds in which 0.135 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org