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 06 April 2004, 04:17 PM
  #1  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
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
Old 07 April 2004, 12:27 AM
  #2  
jods
Scooby Senior
 
jods's Avatar
 
Join Date: Feb 2002
Location: UK
Posts: 6,645
Received 0 Likes on 0 Posts
Default

Have you tried using Microsoft Package and Deployment App to create an EXE from your script ?
Old 07 April 2004, 10:34 AM
  #3  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
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??
Old 07 April 2004, 10:38 AM
  #4  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
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
Old 07 April 2004, 04:27 PM
  #5  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
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
Old 08 April 2004, 12:14 PM
  #6  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
Default

David,

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

Stefan
Old 08 April 2004, 12:18 PM
  #7  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
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
Old 08 April 2004, 02:55 PM
  #8  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

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

David
Old 08 April 2004, 02:58 PM
  #9  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
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
Old 08 April 2004, 02:59 PM
  #10  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

Doesnt quite do what you want, but its better than adding printers!
Old 08 April 2004, 03:20 PM
  #11  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
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
Old 08 April 2004, 03:27 PM
  #12  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
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
Old 08 April 2004, 04:20 PM
  #13  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

LMFAO.
Old 08 April 2004, 05:12 PM
  #14  
Nog
Scooby Regular
 
Nog's Avatar
 
Join Date: Jul 2003
Posts: 141
Likes: 0
Received 0 Likes on 0 Posts
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?
Old 08 April 2004, 06:03 PM
  #15  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
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
Old 09 April 2004, 01:02 PM
  #16  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Default

force a reboot on them all..

David
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
slimwiltaz
General Technical
20
09 October 2015 07:40 PM
IanG1983
Wheels, Tyres & Brakes
2
06 October 2015 03:08 PM
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM
the shreksta
Other Marques
26
01 October 2015 02:30 PM



Quick Reply: VBScript question



All times are GMT +1. The time now is 12:01 PM.