First things first.......
I'm trying to get a list of network mapped printers on all of the
workstations in our domain and put into a file. The following DOES work if
ran locally, but NOT if executed from a remote computer. Below lists the
local vbs script that is trying to be executed and the script from the server
that tries to execute the local script. Any ideas would be helpful.

PS: I'm not the finest code writer......just starting

Thanks,
Brian

------------------------------------------------------
Below script runs and tries to execute a script on each workstation
-------------------------------------------------------
Function findprinters(strcomputer)

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Scripts\printers_local.vbs", "\\" & strcomputer &
"\C$\Admin\", True

Set objWMIService = GetObject ("winmgmts:\\" &
"{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2:Win32_Process")
' Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

objWMIService.Create "cscript.exe c:\admin\printers_local.vbs", null, null,
intProcessID

wscript.sleep(2000)

End Function

-----------------------------------------------------
local vbs script on workstations that puts printers into a file
-----------------------------------------------------
strComputer = "."

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("\\nywpsmsm03\printer_logs\" &
"printer_log_" & datestring & ".txt", ForAppending)

Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
For Each objPrinter in colPrinters
strstring = strstring & objprinter.name & "*"
Next

objTextFile.Write strstring & vbcrlf

---------------------------------------------------

Re: How to execute remote vbscript by ThatsIT

ThatsIT
Fri Jul 27 10:17:32 CDT 2007

try this
http://dev.thatsit.net.au/samples/wsh/thatsit/miso/remote.asp

"BrianB" <BrianB@discussions.microsoft.com> wrote in message
news:4A319BEF-4228-4924-BDC0-EF163048071E@microsoft.com...
> First things first.......
> I'm trying to get a list of network mapped printers on all of the
> workstations in our domain and put into a file. The following DOES work
> if
> ran locally, but NOT if executed from a remote computer. Below lists the
> local vbs script that is trying to be executed and the script from the
> server
> that tries to execute the local script. Any ideas would be helpful.
>
> PS: I'm not the finest code writer......just starting
>
> Thanks,
> Brian
>
> ------------------------------------------------------
> Below script runs and tries to execute a script on each workstation
> -------------------------------------------------------
> Function findprinters(strcomputer)
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFile "C:\Scripts\printers_local.vbs", "\\" & strcomputer &
> "\C$\Admin\", True
>
> Set objWMIService = GetObject ("winmgmts:\\" &
> "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2:Win32_Process")
> ' Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> objWMIService.Create "cscript.exe c:\admin\printers_local.vbs", null,
> null,
> intProcessID
>
> wscript.sleep(2000)
>
> End Function
>
> -----------------------------------------------------
> local vbs script on workstations that puts printers into a file
> -----------------------------------------------------
> strComputer = "."
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile("\\nywpsmsm03\printer_logs\" &
> "printer_log_" & datestring & ".txt", ForAppending)
>
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
> For Each objPrinter in colPrinters
> strstring = strstring & objprinter.name & "*"
> Next
>
> objTextFile.Write strstring & vbcrlf
>
> ---------------------------------------------------
>
>
>



Re: How to execute remote vbscript by BrianB

BrianB
Fri Jul 27 10:28:04 CDT 2007

I did this on one of the machines, but it still failed. Thanks, though.

"ThatsIT.net.au" wrote:

> try this
> http://dev.thatsit.net.au/samples/wsh/thatsit/miso/remote.asp
>
> "BrianB" <BrianB@discussions.microsoft.com> wrote in message
> news:4A319BEF-4228-4924-BDC0-EF163048071E@microsoft.com...
> > First things first.......
> > I'm trying to get a list of network mapped printers on all of the
> > workstations in our domain and put into a file. The following DOES work
> > if
> > ran locally, but NOT if executed from a remote computer. Below lists the
> > local vbs script that is trying to be executed and the script from the
> > server
> > that tries to execute the local script. Any ideas would be helpful.
> >
> > PS: I'm not the finest code writer......just starting
> >
> > Thanks,
> > Brian
> >
> > ------------------------------------------------------
> > Below script runs and tries to execute a script on each workstation
> > -------------------------------------------------------
> > Function findprinters(strcomputer)
> >
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > objFSO.CopyFile "C:\Scripts\printers_local.vbs", "\\" & strcomputer &
> > "\C$\Admin\", True
> >
> > Set objWMIService = GetObject ("winmgmts:\\" &
> > "{impersonationLevel=impersonate}!\\" & strComputer &
> > "\root\cimv2:Win32_Process")
> > ' Set objWMIService = GetObject("winmgmts:" &
> > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> >
> > objWMIService.Create "cscript.exe c:\admin\printers_local.vbs", null,
> > null,
> > intProcessID
> >
> > wscript.sleep(2000)
> >
> > End Function
> >
> > -----------------------------------------------------
> > local vbs script on workstations that puts printers into a file
> > -----------------------------------------------------
> > strComputer = "."
> >
> > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > Set objTextFile = objFSO.OpenTextFile("\\nywpsmsm03\printer_logs\" &
> > "printer_log_" & datestring & ".txt", ForAppending)
> >
> > Set objWMIService = GetObject("winmgmts:" &
> > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> > Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
> > For Each objPrinter in colPrinters
> > strstring = strstring & objprinter.name & "*"
> > Next
> >
> > objTextFile.Write strstring & vbcrlf
> >
> > ---------------------------------------------------
> >
> >
> >
>
>
>

Re: How to execute remote vbscript by Paul

Paul
Fri Jul 27 12:00:29 CDT 2007


"BrianB" <BrianB@discussions.microsoft.com> wrote in message
news:4A319BEF-4228-4924-BDC0-EF163048071E@microsoft.com...
> First things first.......
> I'm trying to get a list of network mapped printers on all of the
> workstations in our domain and put into a file. The following DOES work
> if
> ran locally, but NOT if executed from a remote computer. Below lists the
> local vbs script that is trying to be executed and the script from the
> server
> that tries to execute the local script. Any ideas would be helpful.
>
> PS: I'm not the finest code writer......just starting
>
> Thanks,
> Brian
>
> ------------------------------------------------------
> Below script runs and tries to execute a script on each workstation
> -------------------------------------------------------
> Function findprinters(strcomputer)
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFile "C:\Scripts\printers_local.vbs", "\\" & strcomputer &
> "\C$\Admin\", True
>
> Set objWMIService = GetObject ("winmgmts:\\" &
> "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2:Win32_Process")
> ' Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> objWMIService.Create "cscript.exe c:\admin\printers_local.vbs", null,
> null,
> intProcessID
>
> wscript.sleep(2000)
>
> End Function
>
> -----------------------------------------------------
> local vbs script on workstations that puts printers into a file
> -----------------------------------------------------
> strComputer = "."
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile("\\nywpsmsm03\printer_logs\" &
> "printer_log_" & datestring & ".txt", ForAppending)
>
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
> For Each objPrinter in colPrinters
> strstring = strstring & objprinter.name & "*"
> Next
>
> objTextFile.Write strstring & vbcrlf
>
> ---------------------------------------------------

Try here for some Windows Server 2008 printer related VBScript samples:
http://technet2.microsoft.com/windowsserver2008/en/library/69baa34b-d4b3-40ec-bd2f-12d98f7802d51033.mspx?mfr=true

-Paul Randall



Re: How to execute remote vbscript by urkec

urkec
Fri Jul 27 13:36:01 CDT 2007

"BrianB" wrote:

> > > -----------------------------------------------------
> > > local vbs script on workstations that puts printers into a file
> > > -----------------------------------------------------
> > > strComputer = "."
> > >
> > > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > > Set objTextFile = objFSO.OpenTextFile("\\nywpsmsm03\printer_logs\" &
> > > "printer_log_" & datestring & ".txt", ForAppending)
> > >
> > > Set objWMIService = GetObject("winmgmts:" &
> > > "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> > > Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
> > > For Each objPrinter in colPrinters
> > > strstring = strstring & objprinter.name & "*"
> > > Next
> > >
> > > objTextFile.Write strstring & vbcrlf

I think you don't need to copy this to remote computers.You can run it from
local computer, changing strComputer = "." to strComputer = "remote computer
name" .

--
urkec