madinina
asked on
running csccmd at logon script
Dear Expert.
I have created a VB script thar will start when domain user logon. The script will move the offline folder cache from oldserver to new server.
Set objShell = CreateObject(WScript.Shell)
objShell.Run "csccmd /moveshare:\\olderserver\% username%$ \docs \\newserver\%username%$\do cs"
Where %username% is a variable.The problem is I have noticed that the script never run; Could guide me where I am wrong
thsk in advance
I have created a VB script thar will start when domain user logon. The script will move the offline folder cache from oldserver to new server.
Set objShell = CreateObject(WScript.Shell)
objShell.Run "csccmd /moveshare:\\olderserver\%
Where %username% is a variable.The problem is I have noticed that the script never run; Could guide me where I am wrong
thsk in advance
Oh and one more thing i just noticed your code for the object needs double quotes in the brackets like this:
Set objShell = CreateObject("WScript.Shell")
So your code would be like below:
Set objShell = CreateObject("WScript.Shell")
So your code would be like below:
Set objShell = CreateObject("WScript.Shell")
objShell.Run "csccmd /moveshare:\\olderserver\" & sUser & "$\docs \\newserver\" & sUser & "$\docs"
Hi, in VBScript, you need to expand the %USERPROFILE% environment variable to be able to use it.
Regards,
Rob.
Regards,
Rob.
Set objShell = CreateObject("WScript.Shell")
sUser = objShell.ExpandEnvironmentStrings("%USERNAME%")
objShell.Run "csccmd /moveshare:\\olderserver\" & sUser & "$\docs \\newserver\" & sUser & "$\docs"
ASKER
Thks to All. Will have a try and let you know
ASKER
Dear All,
I have created two scripts :
1 - One for computer GPO that run at startup:
regedit.exe CleanCSC.reg /f. where CleanCSC contains these lines
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWA RE\Microso ft\Windows \CurrentVe rsion\NetC ache]
"FormatDatabase"=dword:000 00001
2 - One for User GPO that run at logon:
set objShell = CreateObject("WScript.Shel l")
sUser = objShell.ExpandEnvironment Strings("% USERNAME%" )
strRegKey = "HKCU\Software\Microsoft\W indows\Cur rentVersio n\Explorer \User Shell Folders\Personal"
strRedirectionPath = "\\mosv03.mo.conair.com\%U SERNAME%$\ Data"
strRedirectRegType = "REG_EXPAND_SZ"
' Write the new Personal path
objShell.RegWrite strRegKey, strRedirectionPath, strRedirectRegType
objShell.Run "csccmd /moveshare:\\oldserver\" & sUser & "$\Data \\newserver\" & sUser & "$\Data"
' Variable Destruction
Set objShell = Nothing
I have one doubt. That Computer GPO (clean CSC cache) ran before user GPO (move CSC from old server to new server)
Any suggestions will be appreciated.
Thks in advance
I have created two scripts :
1 - One for computer GPO that run at startup:
regedit.exe CleanCSC.reg /f. where CleanCSC contains these lines
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWA
"FormatDatabase"=dword:000
2 - One for User GPO that run at logon:
set objShell = CreateObject("WScript.Shel
sUser = objShell.ExpandEnvironment
strRegKey = "HKCU\Software\Microsoft\W
strRedirectionPath = "\\mosv03.mo.conair.com\%U
strRedirectRegType = "REG_EXPAND_SZ"
' Write the new Personal path
objShell.RegWrite strRegKey, strRedirectionPath, strRedirectRegType
objShell.Run "csccmd /moveshare:\\oldserver\" & sUser & "$\Data \\newserver\" & sUser & "$\Data"
' Variable Destruction
Set objShell = Nothing
I have one doubt. That Computer GPO (clean CSC cache) ran before user GPO (move CSC from old server to new server)
Any suggestions will be appreciated.
Thks in advance
>> That Computer GPO (clean CSC cache) ran before user GPO (move CSC from old server to new server)
That is the way it is designed to run. Computer Scripts run before anyone logs in.
Will this actually create a problem though? Does setting FormatDatabase to any value actually delete all cached files?
Regards,
Rob.
That is the way it is designed to run. Computer Scripts run before anyone logs in.
Will this actually create a problem though? Does setting FormatDatabase to any value actually delete all cached files?
Regards,
Rob.
ASKER
Hi RobSampson,
Yeah... it will . Because running clean CSC cache before moving CSC cache will delete all cached files.
Madinina
Yeah... it will . Because running clean CSC cache before moving CSC cache will delete all cached files.
Madinina
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
%username% environmental variable needs to be extracted within the script first in order for that to work. I would suggest the following code.
First, put this on top of your script
Set oNet = CreateObject("wscript.netw
sUser = oNet.UserName
and then use the code below instead your code:
Open in new window