Hi,
I've created a VBScript called: RenameFolder.vbs
When the user logon for the first time, the script will check user's folders redirection (7_Documents, 7_Desktop and 7_Favorites) on %homeshare% then rename those folders to %homeshare%\Desktop, %homeshare%\Favorites, %homeshare%\Documents.
When the script run successfully, it will create a registry entry "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RenameFolder"
So, the script will not run again for the second time.
Problem:
1. The script was run without any error but doesn't rename those folders
Could anyone please help me to double check what went wrong with the script?
==================================================================================
Option Explicit
'Declare Variables
Dim strRoot, ObjFSO, WshShell
Dim Shell, UserVar_HOMESHARE, strCheck, strModfy
'Set objects
Set WshShell = CreateObject("WScript.Shell")
Set Shell = WshShell.Environment("PROCESS")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
strRoot = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RenameFolder"
strCheck = WshShell.RegRead(strRoot)
'Read Environment Variable
UserVar_HOMESHARE = Shell("HOMESHARE")
If strCheck = "1" Then
'This script has already been executed for this user, do nothing
ElseIf UserVar_HOMESHARE = "" Then
' FolderRedirection is Not renamed, do nothing
Else ObjFSO.MoveFolder "%homeshare%\7_desktop" , "%homeshare%\Desktop"
ObjFSO.MoveFolder "%homeshare%\7_documents" , "%homeshare%\Documents"
ObjFSO.MoveFolder "%homeshare%\7_Favorites" , "%homeshare%\Favorites"
StrRoot = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RenameFolder"
strModfy = WshShell.RegWrite(strRoot,"1","REG_SZ")
End If
Set ObjFSO = nothing
Set Shell = nothing
Set WshShell = Nothing
wscript.Quit
=====================================================================================================================
I've created a VBScript called: RenameFolder.vbs
When the user logon for the first time, the script will check user's folders redirection (7_Documents, 7_Desktop and 7_Favorites) on %homeshare% then rename those folders to %homeshare%\Desktop, %homeshare%\Favorites, %homeshare%\Documents.
When the script run successfully, it will create a registry entry "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RenameFolder"
So, the script will not run again for the second time.
Problem:
1. The script was run without any error but doesn't rename those folders
Could anyone please help me to double check what went wrong with the script?
==================================================================================
Option Explicit
'Declare Variables
Dim strRoot, ObjFSO, WshShell
Dim Shell, UserVar_HOMESHARE, strCheck, strModfy
'Set objects
Set WshShell = CreateObject("WScript.Shell")
Set Shell = WshShell.Environment("PROCESS")
Set ObjFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
strRoot = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RenameFolder"
strCheck = WshShell.RegRead(strRoot)
'Read Environment Variable
UserVar_HOMESHARE = Shell("HOMESHARE")
If strCheck = "1" Then
'This script has already been executed for this user, do nothing
ElseIf UserVar_HOMESHARE = "" Then
' FolderRedirection is Not renamed, do nothing
Else ObjFSO.MoveFolder "%homeshare%\7_desktop" , "%homeshare%\Desktop"
ObjFSO.MoveFolder "%homeshare%\7_documents" , "%homeshare%\Documents"
ObjFSO.MoveFolder "%homeshare%\7_Favorites" , "%homeshare%\Favorites"
StrRoot = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\RenameFolder"
strModfy = WshShell.RegWrite(strRoot,"1","REG_SZ")
End If
Set ObjFSO = nothing
Set Shell = nothing
Set WshShell = Nothing
wscript.Quit
=====================================================================================================================