Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1511
  • Last Modified:

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
0
llarava
Asked:
llarava
  • 2
1 Solution
 
vikas_madhusudanaCommented:
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
0
 
llaravaAuthor Commented:
I would like to keep the same type of script. With the IF structure and also the taskkill /IM.

Could anyone help out?
0
 
RobSampsonCommented:
All you should need is:

objShell.Run "taskkill /IM winword.exe",1,true
objFSO.CopyFile "\\server\Shared\Normal.dot", "C:\Program Files\Microsoft Office\Templates\", True

Regards,

Rob.
0
 
vikas_madhusudanaCommented:
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

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now