Hello Everyone,
I am finally calling uncle and looking for some help on what should be a simple VB script.
What I am trying to do is delete a file from a certain path based on the user profile.
Here is what I have so far, I have removed information which I can't disclose per say. . .
That last few times I have been getting Permission denied errors however everything which is targeted can be executed at the permission level.
Before that I was getting ExpandEnviromentStrings errors where it wouldn't produce the %USERNAME% variable as it should.
Long story short. . . help
I am finally calling uncle and looking for some help on what should be a simple VB script.
What I am trying to do is delete a file from a certain path based on the user profile.
Here is what I have so far, I have removed information which I can't disclose per say. . .
Code:
Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")
Dim oShell : Set oShell = CreateObject("WScript.Shell")
Dim obj : Set obj = CreateObject("Scripting.FileSystemObject")
Dim strUserName : strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
WshShell = Nothing
'Kills task to allow file delete'
oShell.Run "TASKKILL /IM tasktobekilled.exe", , True
'Sleeps script to allow for task to end'
WScript.sleep 3000
'Deletes the DB file which holds the records'
obj.DeleteFile("C:\Users\" & strUserName & "\remainderpathtodbfile.com.db")
oShell.Run("""C:\Program Files\remainderpathtoapp.exe""")
That last few times I have been getting Permission denied errors however everything which is targeted can be executed at the permission level.
Before that I was getting ExpandEnviromentStrings errors where it wouldn't produce the %USERNAME% variable as it should.
Long story short. . . help