I am trying to delete a file (Outlook name completion cache fiel) located within a users profile via a vbscript. For example:
c:\Documents and Settings\username\Application Data\Microsoft\Outlook\outlook.n2k
I can write a script to delete a file within a specified directory but I can't get a script to work when username is part of the directory path. Here is what I have started working on if anyone can lend a hand. I have taken the script that deletes a specified file location and have tried to add the network.username variable. When I run this script I get the following error:
Line 4 Char 1
Object required: "[string: "jsmith"]'
Note: jsmith is just an exampel of who is logged in at the time.
dim filesys, demofile
set filesys = CreateObject ("Scripting.FileSystemObject")
set network=createObject("wscript.network")
set username=network.username
set demofile = filesys.GetFile("c:\Documents and Settings\username\Application Dta\Microsoft\Outlook\test.txt")
demofile.Delete
c:\Documents and Settings\username\Application Data\Microsoft\Outlook\outlook.n2k
I can write a script to delete a file within a specified directory but I can't get a script to work when username is part of the directory path. Here is what I have started working on if anyone can lend a hand. I have taken the script that deletes a specified file location and have tried to add the network.username variable. When I run this script I get the following error:
Line 4 Char 1
Object required: "[string: "jsmith"]'
Note: jsmith is just an exampel of who is logged in at the time.
dim filesys, demofile
set filesys = CreateObject ("Scripting.FileSystemObject")
set network=createObject("wscript.network")
set username=network.username
set demofile = filesys.GetFile("c:\Documents and Settings\username\Application Dta\Microsoft\Outlook\test.txt")
demofile.Delete