Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

VBScript question

Thread Tools
 
Search this Thread
 
Old Apr 6, 2004 | 04:17 PM
  #1  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Question VBScript question

Right, I have a very simple script file which installs some printers for a workstation. Now I want to run this for every user, but not through a login script.

I tried using AT and PSEXEC to push the script out to the clients, but the don't like (or simply won't) execute VBScript.

Can a script file be compiled into an .exe binary or do I need to re-write it in VB (or whatever else)?

Code:
'VB script to add printers 
Set WshNetwork = CreateObject("WScript.Network") 

Dim MyVar
	PrinterPath = "\\svr-liv-dc1\HP4050N" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc1\HP4050NA" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc1\HP4050NB" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc1\HP1220C" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc1\EPC900" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath
	
	PrinterPath = "\\svr-liv-dc2\HP4050N" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc2\HP4050NA" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc2\HP4050NB" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc2\HP1220C" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath

	PrinterPath = "\\svr-liv-dc2\EPC900" 
	WshNetwork.AddWindowsPrinterConnection PrinterPath
Stefan
Reply
Old Apr 7, 2004 | 12:27 AM
  #2  
jods's Avatar
jods
Scooby Senior
 
Joined: Feb 2002
Posts: 6,645
Likes: 0
From: UK
Default

Have you tried using Microsoft Package and Deployment App to create an EXE from your script ?
Reply
Old Apr 7, 2004 | 10:34 AM
  #3  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

How do you want it to run.. if your using something like at then did you use /interactive..

What OS are on the remote machines? what rights do you have on them.. I have a script that will remotely execute things??
Reply
Old Apr 7, 2004 | 10:38 AM
  #4  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

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

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)
If Error = 0 Then
    Wscript.Echo "Notepad was started with a process ID of " _
         & intProcessID & "."
Else
    Wscript.Echo "Notepad could not be started due to error " & _
        Error & "."
End If
Reply
Old Apr 7, 2004 | 04:27 PM
  #5  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Default

Jods,

No, I've never heard of those otherwise I would have

David,

Machines are all XP and I have full admin rights to our domain and PC's. If I save my code as .vbs it runs perfectly. Rather than asking the users to run it I want it to launch on their workstations (as the current logged in user). Basically as if I walked up to the desktops and just asked the user to run the VBScript.

Stefan
Reply
Old Apr 8, 2004 | 12:14 PM
  #6  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Default

David,

Tried your little app, but it runs the process as my userid and not the currently logged in user.

Stefan
Reply
Old Apr 8, 2004 | 12:18 PM
  #7  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Default

Even tried using Dameware, but all the remote commands want to use my username and profile. I need to use the currently logged on users profile/environment to launch the utility.

Oh, well looks like I'll need to get them to run the file themselves.

Stefan
Reply
Old Apr 8, 2004 | 02:55 PM
  #8  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

stick it as a shortcut in the startup folder.. urgh.

David
Reply
Old Apr 8, 2004 | 02:58 PM
  #9  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default Bored? Work in IT?

I'm bored...

Save the following as something like lock.vbs
ammend the computernamehere to the target pc's hostname....

then type cscript lock.vbs

and there pc locks.. funny as **** watching their faces..

David

Code:
strComputer = "ComputerNameHere"

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

Error = objWMIService.Create("rundll32.exe user32.dll,LockWorkStation", null, null, intProcessID)

If Error = 0 Then
    Wscript.Echo "Sucesss"
Else
    Wscript.Echo "Failed"
End If
Reply
Old Apr 8, 2004 | 02:59 PM
  #10  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

Doesnt quite do what you want, but its better than adding printers!
Reply
Old Apr 8, 2004 | 03:20 PM
  #11  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Default

Don't worry I'm as fed up as you this afternoon (he says with copy of Evo in front of him). Now, who shall I try this out on ..............

Stefan
Reply
Old Apr 8, 2004 | 03:27 PM
  #12  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Default

Just did it to all the development lads PC's on mass. You'd think butter wouldn't melt in my mouth when I looked over at all the commotion
Reply
Old Apr 8, 2004 | 04:20 PM
  #13  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

LMFAO.
Reply
Old Apr 8, 2004 | 05:12 PM
  #14  
Nog's Avatar
Nog
Scooby Regular
 
Joined: Jul 2003
Posts: 141
Likes: 0
Default

The task scheduler should be able to launch VBS. Did you explicitly prefix the command with the CSCRIPT.EXE interpreter? Not sure how this will work with the currently logged on user. I agree /interactive will get it to run on the desktop, but still not sure who's HKCU reg hive gets updated.

You say you don't want to run it as part of the logon script - any reason?
Reply
Old Apr 8, 2004 | 06:03 PM
  #15  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Default

Nog, I didn't. cscript.exe should work with the vbs file - good thinking

The users never logout. I keep telling them Microsoft like reboots

Stefan
Reply
Old Apr 9, 2004 | 01:02 PM
  #16  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Default

force a reboot on them all..

David
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
Nov 4, 2021 07:12 PM
slimwiltaz
General Technical
20
Oct 9, 2015 07:40 PM
IanG1983
Wheels, Tyres & Brakes
2
Oct 6, 2015 03:08 PM
Brzoza
Engine Management and ECU Remapping
1
Oct 2, 2015 05:26 PM
the shreksta
Other Marques
26
Oct 1, 2015 02:30 PM




All times are GMT +1. The time now is 10:21 AM.