eludlow
asked on
Copy file accross a network
I have a DLL that I wish to publish accross my network into C:\windows\system32 on each station, and then create a registry entry that refers to the DLL.
I wrote a VB script that I could call at startup through AD to do this, but because the PC wasn't logged in, the machine had no permission to write into C:\windows\system32.
So how would others go about this? The script needs only to be run once, as the file and reg entry will only need to be created once.
Many thanks,
Ed Ludlow
I wrote a VB script that I could call at startup through AD to do this, but because the PC wasn't logged in, the machine had no permission to write into C:\windows\system32.
So how would others go about this? The script needs only to be run once, as the file and reg entry will only need to be created once.
Many thanks,
Ed Ludlow
To do that you need to login as administrator...
ASKER
Is there a way this can be done within a script? And then the script log you out?
E
E
You could write a script that would push it out to all computers on the network (assuming they are all on). Then only you would need to be logged on as an administrator. You would copy it into the admin share on the remote machine (\\machinename\C$\windows\ system32). You can find all the templates you need at
http://www.microsoft.com/technet/scriptcenter/default.mspx
If you need any further help, just let me know.
David
http://www.microsoft.com/technet/scriptcenter/default.mspx
If you need any further help, just let me know.
David
ASKER
So I'd need to be logged on as an admin on every machine at the same time for the script to work?
Could be a problem on a 160+ station network.
Thanks for your help though!
E
Could be a problem on a 160+ station network.
Thanks for your help though!
E
By the way, you can do this through the group policy. You need domain admin password for that. Create policy group on the server, assign proper rights and logon/logoff scripts and voila!
Read here about group policy: http://www.microsoft.com/windowsserver2003/technologies/management/grouppolicy/default.mspx
Read here about group policy: http://www.microsoft.com/windowsserver2003/technologies/management/grouppolicy/default.mspx
ASKER
Still not getting this.
It tried to run at startup:
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
objFSO.CopyFile "\\net\Software$\my2msgina .dll" , "C:\windows\system32", OverwriteExisting
But simply get a permission error.
What's up?
E
It tried to run at startup:
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.Fi
objFSO.CopyFile "\\net\Software$\my2msgina
But simply get a permission error.
What's up?
E
As per my previous comment, no you would not need to be logged on as admin at all the workstations, only at your own workstations. However, you would need to have those machines powered on (it won't queue a copy for the next time it is powered on or anything like that). Your script would look something like:
'----Start Code----
On Error Resume Next
Const ForAppending = 8
strDomain = "yourdomainname"
Set objDomain = GetObject("WinNT://" & strDomain)
objDomain.Filter = Array("computer")
On Error Resume Next
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objUpdateLog = objFSO.OpenTextFile("C:\sc ripts\Upda teDll.txt" , ForAppending, True)
Set objWMIService = GetObject("winmgmts:\\.\ro ot\cimv2")
For each objComputer in objDomain
strComputer=objComputer.Na me
wscript.Echo "Working on " & strComputer
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PingStatus " & "Where Address = '" & strComputer & "'")
For Each objItem in colItems
If objItem.StatusCode = 0 Then
objFSO.CopyFile "\\net\Software$\my2msgina .dll" , "C:\windows\system32", OverwriteExisting
wscript.echo strComputer & " responded to ping."
objUpdateLog.Write strComputer & " updated."
objUpdateLog.WriteLine
Else
objUpdateLog.Write strComputer & " not updated."
wscript.echo strComputer & " did not respond to a ping."
objUpdateLog.WriteLine
End If
Next
Next
objUpdateLog.close
'------end code-----
I have tested this to make sure it works in its basic form. If you wanted to get a little more complex, you could have this write out to a text file every computer that did not respond to the ping, with a writeline after it. You can then make a modification to the script that would only read from the text file for the list of computers. Then delete from the text file any computer that responds to a ping after that. This would allow you to run it several times during the day and it would only try to update the machines that have not already been updated. To run this script, you MUST be running Windows XP and logged on with Admin rights. You must also change the domain name (strDomain). You might want to run this script from the command prompt also by doing "cscript scriptname.vbs". It will run much fast if you do that, and there will be no box to hit ok on every time it does or does not respond do a ping (instead it will print in the command box).
If this doesn't work, or you have any more questions, just let me know.
David
'----Start Code----
On Error Resume Next
Const ForAppending = 8
strDomain = "yourdomainname"
Set objDomain = GetObject("WinNT://" & strDomain)
objDomain.Filter = Array("computer")
On Error Resume Next
Set objFSO = CreateObject("Scripting.Fi
Set objUpdateLog = objFSO.OpenTextFile("C:\sc
Set objWMIService = GetObject("winmgmts:\\.\ro
For each objComputer in objDomain
strComputer=objComputer.Na
wscript.Echo "Working on " & strComputer
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PingStatus " & "Where Address = '" & strComputer & "'")
For Each objItem in colItems
If objItem.StatusCode = 0 Then
objFSO.CopyFile "\\net\Software$\my2msgina
wscript.echo strComputer & " responded to ping."
objUpdateLog.Write strComputer & " updated."
objUpdateLog.WriteLine
Else
objUpdateLog.Write strComputer & " not updated."
wscript.echo strComputer & " did not respond to a ping."
objUpdateLog.WriteLine
End If
Next
Next
objUpdateLog.close
'------end code-----
I have tested this to make sure it works in its basic form. If you wanted to get a little more complex, you could have this write out to a text file every computer that did not respond to the ping, with a writeline after it. You can then make a modification to the script that would only read from the text file for the list of computers. Then delete from the text file any computer that responds to a ping after that. This would allow you to run it several times during the day and it would only try to update the machines that have not already been updated. To run this script, you MUST be running Windows XP and logged on with Admin rights. You must also change the domain name (strDomain). You might want to run this script from the command prompt also by doing "cscript scriptname.vbs". It will run much fast if you do that, and there will be no box to hit ok on every time it does or does not respond do a ping (instead it will print in the command box).
If this doesn't work, or you have any more questions, just let me know.
David
ASKER
Thanks for this - now getting somewhere!
All the machines that are on are responding to the ping, but the file isn't appearing in system32...and I've double checked it's there in \\net\software$\
Thanks for your help on this so far, getting somewhere now!
E
All the machines that are on are responding to the ping, but the file isn't appearing in system32...and I've double checked it's there in \\net\software$\
Thanks for your help on this so far, getting somewhere now!
E
I am sorry, I just realize I made a mistake in the code! I copied your code for coping the file, all that needs to be changed is the line:
objFSO.CopyFile "\\net\Software$\my2msgina .dll" , "C:\windows\system32", OverwriteExisting
Change it to
strCopyLoc = "\\" & strComputer & "\c$\windows\system32"
objFSO.CopyFile "\\net\Software$\my2msgina .dll" , strCopyLoc, OverwriteExisting
And that should work! Once again, sorry about that, I didn't actually try to copy the file as I don't have that file. That should fix it!
David
objFSO.CopyFile "\\net\Software$\my2msgina
Change it to
strCopyLoc = "\\" & strComputer & "\c$\windows\system32"
objFSO.CopyFile "\\net\Software$\my2msgina
And that should work! Once again, sorry about that, I didn't actually try to copy the file as I don't have that file. That should fix it!
David
ASKER
You're not going to like me, but it still won't work :(
This is what I have:
On Error Resume Next
Const ForAppending = 8
strDomain = "langton"
Set objDomain = GetObject("WinNT://" & strDomain)
objDomain.Filter = Array("computer")
On Error Resume Next
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objUpdateLog = objFSO.OpenTextFile("C:\sc ripts\Upda teDll.txt" , ForAppending, True)
Set objWMIService = GetObject("winmgmts:\\.\ro ot\cimv2")
For each objComputer in objDomain
strComputer=objComputer.Na me
wscript.Echo "Working on " & strComputer
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PingStatus " & "Where Address = '" & strComputer & "'")
For Each objItem in colItems
If objItem.StatusCode = 0 Then
strCopyLoc = "\\" & strComputer & "\c$\windows\system32"
objFSO.CopyFile "\\net\Software$\my2msgina .dll" , strCopyLoc, OverwriteExisting
wscript.echo strComputer & " responded to ping."
objUpdateLog.Write strComputer & " updated."
objUpdateLog.WriteLine
Else
objUpdateLog.Write strComputer & " not updated."
wscript.echo strComputer & " did not respond to a ping."
objUpdateLog.WriteLine
End If
Next
Next
objUpdateLog.close
Any ideas?
E
This is what I have:
On Error Resume Next
Const ForAppending = 8
strDomain = "langton"
Set objDomain = GetObject("WinNT://" & strDomain)
objDomain.Filter = Array("computer")
On Error Resume Next
Set objFSO = CreateObject("Scripting.Fi
Set objUpdateLog = objFSO.OpenTextFile("C:\sc
Set objWMIService = GetObject("winmgmts:\\.\ro
For each objComputer in objDomain
strComputer=objComputer.Na
wscript.Echo "Working on " & strComputer
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_PingStatus " & "Where Address = '" & strComputer & "'")
For Each objItem in colItems
If objItem.StatusCode = 0 Then
strCopyLoc = "\\" & strComputer & "\c$\windows\system32"
objFSO.CopyFile "\\net\Software$\my2msgina
wscript.echo strComputer & " responded to ping."
objUpdateLog.Write strComputer & " updated."
objUpdateLog.WriteLine
Else
objUpdateLog.Write strComputer & " not updated."
wscript.echo strComputer & " did not respond to a ping."
objUpdateLog.WriteLine
End If
Next
Next
objUpdateLog.close
Any ideas?
E
Do a start -> run. Then type in "\\net\Software$" and see if it can connect. Is it giving you any error message or is the dll just not in System32? Maybe try putting the dll somewhere local on your machine and changing the path to see if it works then.
David
David
ASKER
\\net\software$\ runs fine from from start -> run.
Will try putting it in C:\ tomorrow morning, and then trying to copy from "C:\my2msgina.dll" .... will report back then!
Again, thanks for you help.
Ed
Will try putting it in C:\ tomorrow morning, and then trying to copy from "C:\my2msgina.dll" .... will report back then!
Again, thanks for you help.
Ed
ASKER
No joy I'm afraid!
E
E
Hum, do you have admin rights on the remote machine? For instance, on one of the machines you are trying to copy the dll to, can you do a start -> run "\\machinename\c$"? If you don't have admin rights on the remote machine, you cannot access the admin share (c$). I will do some testing here to make sure the script is working correctly.
David
David
ASKER
Full admin right, and running \\machinename\c$\whatever works fine - I can access anything on any machine that is turned on.
Play around with a load of combinations of file locations, but doesn't seem to work!
Ed
Play around with a load of combinations of file locations, but doesn't seem to work!
Ed
Ok, after hitting my head on the wall several times, due to it also not working for me, I have determined a solution. The line that says:
strCopyLoc = "\\" & strComputer & "\c$\windows\system32"
Needs to say
strCopyLoc = "\\" & strComputer & "\c$\windows\system32\"
Notice the change? Stupid "\". I just happened to stumble across that (tried righting to the root of the admin share and forgot to delete that "\" and it worked). Sorry, it has apparently been a long week. Hopefully everything works now.
David
strCopyLoc = "\\" & strComputer & "\c$\windows\system32"
Needs to say
strCopyLoc = "\\" & strComputer & "\c$\windows\system32\"
Notice the change? Stupid "\". I just happened to stumble across that (tried righting to the root of the admin share and forgot to delete that "\" and it worked). Sorry, it has apparently been a long week. Hopefully everything works now.
David
ASKER
Thank you so much David, that is now working!
Dead chuffed!
Cheers,
Ed
Dead chuffed!
Cheers,
Ed
ASKER
As a tiny, but not hugely important aside, would it be easy to add something that stops it copying to a couple of machines (the network servers!) that could be specified by name? No worries if not.
Ed
Ed
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah sod it - can't be arsed - can just delete the file from the servers once I've powered up all the machines, run the script and it's done its magic.
Thanks again for your help - will now close this thread.
Thanks again for your help - will now close this thread.