![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| | Vista - how canrun this script on a remote computer |
| |
| 09-11-2008 | #1 |
| | how canrun this script on a remote computer Can anybody help me with this script i found, This local script works fine, but i want this script run on remote computers. Here is the script Option Explicit Dim ZipFile, SrcFldrs, Fldr, iFiles Const FOF_CREATEPROGRESSDLG = &H0& SrcFldrs = Array("C:\Data1", "C:\Data2", "C:\Data3") ZipFile = "C:\Data.zip" 'Create empty Zip File CreateObject("Scripting.FileSystemObject") _ .CreateTextFile(ZipFile, True) _ .Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) iFiles = 0 With CreateObject("Shell.Application") For each Fldr in SrcFldrs 'Copy the files to the compressed folder .NameSpace(ZipFile).CopyHere .NameSpace(Fldr).Items, FOF_CREATEPROGRESSDLG iFiles = iFiles + .NameSpace(Fldr).Items.Count 'Keep script waiting until Compressing is done On Error Resume Next Do Until .NameSpace(ZipFile).Items.Count = iFiles wScript.Sleep 1000 Loop On Error GoTo 0 Next End With |
| My System Specs |
| 09-12-2008 | #2 |
| | Re: how canrun this script on a remote computer "floyd" <w> wrote in message news:48c965fc$0$51244$dbd4b001@xxxxxx Quote: > Can anybody help me with this script i found, > This local script works fine, but i want this script run on remote > computers. that. My suggestion would be to use the AT scheduler. The code below is a little kludgy and thrown together quickly, but it should work. It is a Windows Script File, so give it a 'wsf' extension instead of 'vbs'. Put your list of computers in the <resource> at the top. Your original script is in a <resource> at the bottom. The only change I made was to add a line at the bottom for it to delete itself when done. Basically, what the code should do is create the file on the root of C: on the remote computer & create an AT job to execute it two minutes in the future. Since the script uses the admin share and the AT scheduler, you will need to have admin rights on the computer you are running it on and the computers you are running it against. Code Below: <?xml version="1.0" encoding="ISO-8859-1"?> <job> <resource id="Computers"> Computer1 Computer2 Computer3 </resource> <object id="oWSH" progid="WScript.Shell"/> <object id="oFSO" progid="Scripting.FileSystemObject"/> <script language="VBScript"><![CDATA[ Option Explicit Dim aComputers(), sComputers, sComputer, sDateTime, sTime, sDate Dim sPath ReDim aComputers(-1) sComputers = GetResource("Computers") For Each sComputer in Split(sComputers, vbCrLf) sComputer = Trim(sComputer) If Len(sComputer) Then ReDim Preserve aComputers(UBound(aComputers) + 1) aComputers(UBound(aComputers)) = sComputer End If Next For Each sComputer in aComputers sPath = "\\" & sComputer & "\c$" If oFSO.FolderExists(sPath) Then oFSO.OpenTextFile(sPath & "\ZipCode.vbs", 2, True). _ Write GetResource("ZipCode") If oFSO.FileExists(sPath & "\ZipCode.vbs") Then sDateTime = DateAdd("n", 2, Now) sTime = Right("0" & Hour(sDateTime), 2) & ":" & _ Right("0" & Minute(sDateTime), 2) oWSH.Run "at.exe \\" & sComputer & " " & sTime & _ " c:\ZipCode.vbs", 0, True End If End If Next MsgBox "Done" ]]></script> <resource id="ZipCode"><![CDATA[ Dim ZipFile, SrcFldrs, Fldr, iFiles Const FOF_CREATEPROGRESSDLG = &H0& SrcFldrs = Array("C:\Data1", "C:\Data2", "C:\Data3") ZipFile = "C:\Data.zip" 'Create empty Zip File CreateObject("Scripting.FileSystemObject") _ .CreateTextFile(ZipFile, True) _ .Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) iFiles = 0 With CreateObject("Shell.Application") For each Fldr in SrcFldrs 'Copy the files to the compressed folder .NameSpace(ZipFile).CopyHere .NameSpace(Fldr).Items, _ FOF_CREATEPROGRESSDLG iFiles = iFiles + .NameSpace(Fldr).Items.Count 'Keep script waiting until Compressing is done On Error Resume Next Do Until .NameSpace(ZipFile).Items.Count = iFiles wScript.Sleep 1000 Loop On Error GoTo 0 Next End With CreateObject("Scripting.FileSystemObject"). _ DeleteFile WScript.ScriptFullName ]]></resource> </job> |
| My System Specs |
| 09-12-2008 | #3 |
| | Re: how canrun this script on a remote computer This is what i`m looking for thank you it works. "James Whitlow" <jwhitlow.60372693@xxxxxx> schreef in bericht news:e7%23weNPFJHA.5088@xxxxxx Quote: > "floyd" <w> wrote in message > news:48c965fc$0$51244$dbd4b001@xxxxxx Quote: >> Can anybody help me with this script i found, >> This local script works fine, but i want this script run on remote >> computers. > I know you can use remote execute, but I have not had good luck with > that. My suggestion would be to use the AT scheduler. The code below is a > little kludgy and thrown together quickly, but it should work. It is a > Windows Script File, so give it a 'wsf' extension instead of 'vbs'. Put > your list of computers in the <resource> at the top. Your original script > is in a <resource> at the bottom. The only change I made was to add a line > at the bottom for it to delete itself when done. > > Basically, what the code should do is create the file on the root of C: > on the remote computer & create an AT job to execute it two minutes in the > future. Since the script uses the admin share and the AT scheduler, you > will need to have admin rights on the computer you are running it on and > the computers you are running it against. > > Code Below: > > <?xml version="1.0" encoding="ISO-8859-1"?> > > <job> > <resource id="Computers"> > Computer1 > Computer2 > Computer3 > </resource> > > <object id="oWSH" progid="WScript.Shell"/> > <object id="oFSO" progid="Scripting.FileSystemObject"/> > <script language="VBScript"><![CDATA[ > Option Explicit > Dim aComputers(), sComputers, sComputer, sDateTime, sTime, sDate > Dim sPath > ReDim aComputers(-1) > sComputers = GetResource("Computers") > For Each sComputer in Split(sComputers, vbCrLf) > sComputer = Trim(sComputer) > If Len(sComputer) Then > ReDim Preserve aComputers(UBound(aComputers) + 1) > aComputers(UBound(aComputers)) = sComputer > End If > Next > For Each sComputer in aComputers > sPath = "\\" & sComputer & "\c$" > If oFSO.FolderExists(sPath) Then > oFSO.OpenTextFile(sPath & "\ZipCode.vbs", 2, True). _ > Write GetResource("ZipCode") > If oFSO.FileExists(sPath & "\ZipCode.vbs") Then > sDateTime = DateAdd("n", 2, Now) > sTime = Right("0" & Hour(sDateTime), 2) & ":" & _ > Right("0" & Minute(sDateTime), 2) > oWSH.Run "at.exe \\" & sComputer & " " & sTime & _ > " c:\ZipCode.vbs", 0, True > End If > End If > Next > > MsgBox "Done" > > ]]></script> > <resource id="ZipCode"><![CDATA[ > Dim ZipFile, SrcFldrs, Fldr, iFiles > > Const FOF_CREATEPROGRESSDLG = &H0& > > SrcFldrs = Array("C:\Data1", "C:\Data2", "C:\Data3") > ZipFile = "C:\Data.zip" > > 'Create empty Zip File > CreateObject("Scripting.FileSystemObject") _ > .CreateTextFile(ZipFile, True) _ > .Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar) > > iFiles = 0 > > With CreateObject("Shell.Application") > > For each Fldr in SrcFldrs > 'Copy the files to the compressed folder > .NameSpace(ZipFile).CopyHere .NameSpace(Fldr).Items, _ > FOF_CREATEPROGRESSDLG > > iFiles = iFiles + .NameSpace(Fldr).Items.Count > > 'Keep script waiting until Compressing is done > On Error Resume Next > Do Until .NameSpace(ZipFile).Items.Count = iFiles > wScript.Sleep 1000 > Loop > On Error GoTo 0 > Next > End With > CreateObject("Scripting.FileSystemObject"). _ > DeleteFile WScript.ScriptFullName > ]]></resource> > </job> > |
| My System Specs |
![]() |
| Thread Tools | |
| |
| Similar Threads for: how canrun this script on a remote computer | ||||
| Thread | Forum | |||
| Remote Desktop - Cannot Connect To The Remote Computer | Server General | |||
| Remote desktop can not find remote computer | Network & Sharing | |||
| wshremote not running script on remote computer | VB Script | |||
| Running Script Against Remote Computer | PowerShell | |||
| Remote Script Controller | PowerShell | |||