Link to home
Start Free TrialLog in
Avatar of llarava
llaravaFlag for Afghanistan

asked on

Normal.dot replacement script (vb script)

Hi,

I am not really familiar with scripting however I am trying to modify the following script. The goal is to replace the normal.dot that is located in C:\Program Files\Microsoft Office\Templates

The script below does more since it looks for the user name, renames the file, etc...

Basically the script has to be simplified so the normal.dot gets copied from the server share to the C:\Program Files\Microsoft Office\Templates location.

No need for the file to be renamed and user to be identified since it is place in C:\Program Files instead of the users profile.

Thanks!

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objNetwork : set objNetwork =  CreateObject("Wscript.Network")
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
 
 
strPath = "C:\Documents and Settings\" & objNetwork.UserName
If objFSO.FileExists (strPath & "\application data\microsoft\templates\normal.dot") Then
      If objFSO.FolderExists(strPath & "\application data\microsoft\templates\old-normal") = False Then
            objFSO.CreateFolder strPath & "\application data\microsoft\templates\old-normal"
      End If
      objFSO.CopyFile strPath & "\application data\microsoft\templates\normal.dot", strPath & "\application data\microsoft\templates\old-normal\"
End If
objShell.Run "taskkill /IM winword.exe",1,true
objFSO.CopyFile "\\server\Shared\Normal.dot", strPath & "\application data\microsoft\templates\", True
Avatar of vikas_madhusudana
vikas_madhusudana
Flag of India image

can you try this batch script

net use x: /DELETE
net use x: \\server\Shared\
x:
copy normal.dot "C:\Program Files\Microsoft Office\Templates\"

put this into .bat file and then run
Avatar of llarava

ASKER

I would like to keep the same type of script. With the IF structure and also the taskkill /IM.

Could anyone help out?
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try This
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objNetwork : set objNetwork =  CreateObject("Wscript.Network")
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
 
 
strPath = "C:\Program Files\Microsoft Office\Templates"
If objFSO.FileExists (strPath & "normal.dot") Then
      If objFSO.FolderExists(strPath & "\old-normal") = False Then
            objFSO.CreateFolder strPath & "\old-normal"
      End If
      objFSO.CopyFile strPath & "\normal.dot", strPath & "\old-normal\"
End If
objShell.Run "taskkill /IM winword.exe",1,true
objFSO.CopyFile "\\server\Shared\Normal.dot", strPath & "\", True

Open in new window