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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

1 file, 85 users....

Status
Not open for further replies.

mojo1979

Technical User
Nov 17, 2003
138
US
Hi,

Basically I have one file that needs to be updated to 85 users laptops everyday. I thought about offline files etc, but is there an easier way?

Otherwise manually, its a nightmare task...

Thanks!
 
there is only one?
On error resume next = suppress errors
On error goto 0 = turn on error checking
 
This is what I have:

On error resume Next
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'Create a Path to a log file
Const fileName = "c:\vbslog.txt"

Dim WshShell,WshEnv
Dim WshNetwork:Set WshNetwork = CreateObject("WScript.Network")
Set WshShell = WScript.CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
Set objFSO = CreateObject("Scripting.FileSystemObject")
SysDrive = WshEnv("SYSTEMDRIVE")

Dim objDomain:Set objDomain = getObject("LDAP://rootDse")
Dim DomainString:DomainString = objDomain.Get("dnsHostName")

Dim UserString:UserString = WshNetwork.UserName
Dim objADSysInfo:Set objADSysInfo = CreateObject("ADSystemInfo")
strComputer = WshNetwork.ComputerName

strComputer "."
UserDesktop = WshShell.SpecialFolders("Desktop")

'Your file name
fname = "test.xls"
'Source file location
SFile = SysDrive & "\\dxbserver2\public\" & fname
'Destination Location
Dfile = UserDesktop


'Delete The file
path = UserDesktop & "\" & fname

Set file = objFSO.GetFile(path)
If objFSO.FileExists(path) Then
objFSO.DeleteFile file.Path
End if
'Wait 5 seconds
wscript.sleep 5000

'Log Success and Failure
Set fso = CreateObject("Scripting.FileSystemObject")
If Not FSO.FileExists(Data_Path & filename) Then
Set f = fso_OpenTextFile(Data_Path & fileName,2, True)
Else
Set f = fso_OpenTextFile(Data_Path & fileName,8)
End If

If strComputer = "" Then
f.WriteLine VbCrLf & strComputer &" did not respond."
Else
f.WriteLine VbCrLf & strcomputer & " responded."
objfso.CopyFile SFile, DFile, overwrite = TRUE

'On error resume next
End If
 
When logging on an error message comes up:

Windows Script Host
Script: \\dxbserver1\netlogon\logon.vbs
Line: 22
Char: 1
Error: type mismatch 'strComputer'
Code: 800A000D
 
are you running the script on the local machine, not the server.
strComputer = "." [means local machine]
strComputer = WshNetwork.ComputerName [gets computer name for AD]

You can delete strComputer = ".", I've never had a problem with having both.
 
Ok, deleted it.

Its now getting stuck on line 35:


Set file = objFSO.GetFile(path)

 
See if your getting the users desktop and correct file name. I only get file not found which is why the On error resume next is there.

what does it say if you add this [wscript.echo path]
under

'Delete The file
path = UserDesktop & "\" & fname
wscript.echo path
 
Before the same error message comes up (error line 35), a window that says;

Windows Script Host

\\dxbserver1\users\'username'\test.xls

And then an OK button

Pressing OK, gives the error message as before
 
so your trying to delete a file on
\\dxbserver1\users\'username'\test.xls
You said
so the destination location, if I want the file to be saved to each users desktop, would look like this?

so that is why we used the Desktop

UserDesktop = WshShell.SpecialFolders("Desktop")

'Your file name
fname = "test.xls"
'Source file location YOUR SERVER SHARE
SFile = SysDrive & "\\dxbserver2\public\" & fname
'Destination Location THE USERS DESKTOP
Dfile = UserDesktop


'Delete The file
path = UserDesktop & "\" & fname

so your path should be
path = C:\Documents and Setting\username\desktop\test.xls
 
The user desktop 'folder' redirects to \\dxbserver1\users\$username$\Desktop

So the desktop folder doesn't exist on:

C:\Documents and Setting\username\desktop\
 
I have never worked with redirecting users desktops, but I do believe the correct way is to use off line files.

change this see if it works

'Destination Location
Dfile = "\\dxbserver1\users\" & UserString & "\Desktop"


'Delete The file
path = dfile & "\" & fname
 
To be honest I dont think it will work using the desktop as a destination.

What about if I just dump the file on the user's C: drive?
 
what error?
not sure if your going to need two \\
e.g

'Destination Location
Dfile = "\\dxbserver1\\users\\" & UserString & "\\Desktop"

'Delete The file
path = dfile & "\\" & fname
does the correct path get displayed when using wscript.echo
 
Yeah the correct path shows...

i.e. \\dxbserver1\users\'username'\desktop\test.xls
 
does it delete the file, is there an error file not found and if not found does it exist?
 
Nothing happens, i get the wscript echo and the error message and then nothing...
 
If you sit at the users machine and Start Run and type in
\\dxbserver1\users\'username'\desktop
do you get there desktop on the server?
What is the full error message
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top