[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Logon Script Help - VBS

I am having an impossible time here. We added two new printers. I need to uninstall the two old printers Canon1 and Canon2

And then let the logon script install the two new "Server Room Ricoh Copier" and "Ricoh Color Back Office"

I cannot figure this out, but the logon script does not seem to be working at all. All I did was change the share names. Assuming the Old ones would be removed. Can someone please help me out with this?

I attached the script. It does seem to be working at all. Not mapping drives or fixing the printers?

Please help!

Thanks,

2011.vbs
0
sparkis
Asked:
sparkis
  • 12
  • 6
  • 3
1 Solution
 
Neil RussellTechnical Development LeadCommented:
Why use a script?  If you are on 2008 server then Use Group Policy Preferences and the Print Server Role. Simples.
0
 
Neil RussellTechnical Development LeadCommented:
Also ALL of your drive mappings could be done using Group Policies too. Much cleaner and simpler.
0
 
sparkisAuthor Commented:
What about mapping drives?
I have not problem using GP to push out Printers - But then do I still need the script for the Drives? And if so, Can you help me edit the current one down?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
sparkisAuthor Commented:
how do you do that?
0
 
GlobaLevelCommented:
....you have the experts above...but honestly..I have always had problems with using vbs to switch drives:

strDriveLetter1 = "G:"
strDriveLetter2 = "S:"
strDriveLetter3 = "T:"
strDriveLetter4 = "U:"

It tends to run the first fine..then hangs...I would write 4 separate programs... or use WMI..windows Manangement Instruments...

this has a couple examples to see how it looks..plenty on the internet..
http://motevich.blogspot.com/2007/11/execute-program-on-remote-computer.html

WMI and Printer Tasks:
http://msdn.microsoft.com/en-us/library/aa394598(v=vs.85).aspx

also if you do a google on "wmi remote printer"...TONS!
0
 
GlobaLevelCommented:
...opps let me restate..I have had issues using objNetwork.MapNetworkDrive to switch drives..however WMI / VBScript was great..
0
 
sparkisAuthor Commented:
Ok - willing to try the GPO route -

 So I see where I can deploy printers. That I added in User Config / Windows Settings.
Now I see whre I can add the logon script for to map the drives.

My only question since most machines already have the drives mapped via the logon script - will this cause a conflict - assuming I remove the logon script?

And how do I remove the old printers that are still mapped but no longer exist?
0
 
sparkisAuthor Commented:
GlobalLevel - I am not having any issue with the mapped drives in my logon script. I am having an issue with the printers only

Wanted to have the script remove all network printers, and then install the following on the list.

I posted the script if you can take a look.

Thanks SJMP
0
 
sparkisAuthor Commented:
well taking care of the printers via GPO was extraordinarily easy. And it worked.

So I still need a hand removing two printers via the current logon script.

can someone help me with some scipting expertise.

I want to remove \\server\Canon1 and \\server\Canon2

0
 
sparkisAuthor Commented:
Would this work as a .vbs that I put in logons for GPO


Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "G:", "\\server\Data"
objNetwork.MapNetworkDrive "S:", "\\server\Shared"
objNetwork.MapNetworkDrive "T:", "\\server\Gead"
objNetwork.MapNetworkDrive "U:", "\\server\test"
0
 
Neil RussellTechnical Development LeadCommented:
IN Group policy editor User-> Preferences

Good guide here

http://www.msserveradmin.com/using-group-policy-prefernces-to-map-drives/
0
 
sparkisAuthor Commented:
My script above worked. I just want to make sure that previously mapped printers that no longer exist, will no longer be there. I guess I can confirm further by testing.
0
 
sparkisAuthor Commented:
Guys - I spoke to soon. the script is not working for my users. Any reason based on the script itself?

Option Explicit
On Error Resume Next

Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "G:", "\\fs02\Data"
objNetwork.MapNetworkDrive "S:", "\\fs02\Shared"
objNetwork.MapNetworkDrive "T:", "\\server1\Dead"
objNetwork.MapNetworkDrive "U:", "\\server1\Portfolio"

Wscript.Quit
0
 
Neil RussellTechnical Development LeadCommented:
In the time it took you to ask the question you could have configured a New Group poilicy to do all of the network disk mapping for you :P

Like i said....

http://www.msserveradmin.com/using-group-policy-prefernces-to-map-drives/ 
0
 
sparkisAuthor Commented:
ok thanks. I will look into this.

But back to my original questions. How can I add to the script to remove two networked printers names. Printer 1 and Printer 2?

Thanks,

SJMP

Just want to add it to below:
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "G:", "\\server\Data"
objNetwork.MapNetworkDrive "S:", "\\server\Shared"
objNetwork.MapNetworkDrive "T:", "\\server\Gead"
objNetwork.MapNetworkDrive "U:", "\\server\test"
0
 
sparkisAuthor Commented:
Can I just add this to the script?

Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\printer1"
WshNetwork.RemovePrinterConnection PrinterPath, true, true
PrinterPath = "\\printserv\printer2"
WshNetwork.RemovePrinterConnection PrinterPath, true, true

Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "G:", "\\server\Data"
objNetwork.MapNetworkDrive "S:", "\\server\Shared"
objNetwork.MapNetworkDrive "T:", "\\server\Gead"
objNetwork.MapNetworkDrive "U:", "\\server\test"
0
 
Neil RussellTechnical Development LeadCommented:
From memory removeprinterconnectin has all sorts of problems trying to remove 'stale' network printers. I.e. ones that no longer exist.  If you have changed the share name and are now trying to remove them, this could be an issue.
0
 
sparkisAuthor Commented:
The printers themselves are gone. The Canon's were replaced with Ricoh's.

I just want to remove the two.
0
 
GlobaLevelCommented:
If your going the vb route...have you tried running two separate scripts one for each printer?
0
 
Neil RussellTechnical Development LeadCommented:
OK, have a read of this long thread here, should solve your removal problem one way or the other,

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_24040284.html
0
 
sparkisAuthor Commented:
did not address logon script but gave decent alternative.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 12
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now