Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to delete a few files and replace them

Status
Not open for further replies.

Ravenrx7

IS-IT--Management
Aug 21, 2002
109
US
Hello,

I dont know if i'm evening posting this in the correct section, but its a very basic script issue im having, im just clueless on this scripts. I'm using visual basic, and I've attached the code below, i took over the admin position here, so i got to try to figure out why this code is not deleting the (3) listed files at the bottom of the code fand copying them from the server ( waps-dc2) to the user's windows folder, they're was alot more to this code but i reduced it since this is where the issue is
'*********************************************************
' Declare Vars
'*********************************************************
DIM wshNet
DIM strUser
DIM datadir
dim windir
DIM drivetally
Set DriveNet = WScript.CreateObject("WScript.Network")
Set CheckDrive = DriveNet.EnumNetworkDrives()
Set wshNet = WScript.CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("WScript.Shell")
DriveLetter = "P:"
strUser = wshNet.UserName
startDir = "C:\Documents and Settings\" & strUser & "\Start Menu\Programs\"
deskDir = "C:\Documents and Settings\" & strUser & "\Desktop\"
winDir= "C:\Documents and Settings\" & strUser & "\WINDOWS\"
dataDir = "\\WAPS-dc1\" & strUser &"$"



'*********************************************************
' STARREADING - 11/07/06, 01/23/07
'*********************************************************
if fso.FileExists(winDir) then
if fso.FileExists(winDir & "ALSBIGC.DAT") Then
set DelShort = fso.GetFile(winDir & "ALSBIGC.DAT")
DelShort.Delete
end if
if fso.FileExists(winDir & "ALSBIGC.FPT") Then
set DelShort = fso.GetFile(winDir & "ALSBIGC.FPT")
DelShort.Delete
end if
if fso.FileExists(winDir & "ALSPREFS.INI") Then
set DelShort = fso.GetFile(winDir & "ALSPREFS.INI")
DelShort.Delete
end if
fso.CopyFile "\\waps-dc2\starfiles$\ALSBIGC.DAT", winDir
fso.CopyFile "\\waps-dc2\starfiles$\ALSBIGC.FPT", winDir
fso.CopyFile "\\waps-dc2\starfiles$\ALSPREFS.INI", winDir
End if

'*********************************************************
' End of Script
Josh McMahon
A+ Certified,CCNA


Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
I'm not sure what specifically is happening, but rather than checking to see if a file exists and then deleting it, then copying down a new version, I just copy down the new version and overwrite the one that is there. The syntax would be:

fso.CopyFile "\\waps-dc2\starfiles$\ALSBIGC.DAT", winDir, True
 
ok let me try that.. thanks again

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
it should look like this correct? norhting at the bottom?
it ran but it didnt work, no errors either

DIM wshNet
DIM strUser
DIM datadir
dim windir
DIM drivetally
Set DriveNet = WScript.CreateObject("WScript.Network")
Set CheckDrive = DriveNet.EnumNetworkDrives()
Set wshNet = WScript.CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("WScript.Shell")
DriveLetter = "P:"
strUser = wshNet.UserName
startDir = "C:\Documents and Settings\" & strUser & "\Start Menu\Programs\"
deskDir = "C:\Documents and Settings\" & strUser & "\Desktop\"
winDir= "C:\Documents and Settings\" & strUser & "\WINDOWS\"
dataDir = "\\WAPS-dc1\" & strUser &"$"


fso.CopyFile "\\waps-dc2\starfiles$\ALSBIGC.DAT", winDir, True

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
That looks correct to me. You're positive that it isn't updating the files? You mentioned earlier that you trimmed out a lot of the script for brevity, is there an "On Error Resume Next" line in there somewhere? If there is, that would be preventing the error message from displaying. Also, is this routine nested somewhere in a subroutine/if...then/case statement? If so, it may never be executing if the requirements aren't being met.
 
i basically just wanted to run this script first, AD should run this script when the user logs on, no errors or anything, looks simple now, just copy that file and replace whats current

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
Ah. I saw another case like this earlier today. Do you have a GPO configured to cause XP clients to wait for the network on startup? If not, this script could be executing before the network is initialized, which means that your UNC paths won't work.

What happens if you run the script manually after you have already logged in?

Look here for details on the GPO:

 
humm good point, i tried to run it manually and the script still didnt work, no errors, permissions are ok

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
here is the deal, basically there are 3 files on a server which need to transfer to the user's profile ex(c:\docs & settings\jmcmahon\windows) into the WINDOWS FOLDER, we can run it by vbscript, batch, using AD so any way you guys can think of would work. Seems like that code to replace those file would work but its not

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
so i found solution, using good old command prompt,

NET USE Z: /DELETE /YES
NET USE Z: \\WAPS-DC2\STARFILES$

ECHO **COPYING STAR READING FILES **
COPY Z:\*.* %USERPROFILE%\WINDOWS\



Only thing i get this error now, "The filename, directory name, or volume label syntax is incorrect."

I thinks its on the %USERPROFILE%\WINDOWS part..?
Simple fix?

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
COPY Z:\*.* "%USERPROFILE%\WINDOWS\*.*"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OMG I GOT IT!!

NET USE Z: /DELETE /YES
NET USE Z: \\WAPS-DC2\STARFILES$

ECHO **COPYING STAR READING FILES **


cd %userprofile%\windows

COPY Z:\*.*

NET USE Z: /DELETE /YES

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top