ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   VBScript question (https://www.scoobynet.com/computer-and-technology-related-34/317012-vbscript-question.html)

ozzy 06 April 2004 04:17 PM

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

jods 07 April 2004 12:27 AM

Have you tried using Microsoft Package and Deployment App to create an EXE from your script ?

David_Wallis 07 April 2004 10:34 AM

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??

David_Wallis 07 April 2004 10:38 AM

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


ozzy 07 April 2004 04:27 PM

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

ozzy 08 April 2004 12:14 PM

David,

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

Stefan

ozzy 08 April 2004 12:18 PM

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

David_Wallis 08 April 2004 02:55 PM

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

David

David_Wallis 08 April 2004 02:58 PM

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 fook 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


David_Wallis 08 April 2004 02:59 PM

Doesnt quite do what you want, but its better than adding printers!

ozzy 08 April 2004 03:20 PM

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

ozzy 08 April 2004 03:27 PM

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 :D

David_Wallis 08 April 2004 04:20 PM

LMFAO.

Nog 08 April 2004 05:12 PM

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?

ozzy 08 April 2004 06:03 PM

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

David_Wallis 09 April 2004 01:02 PM

force a reboot on them all..

David


All times are GMT +1. The time now is 03:12 AM.


© 2024 MH Sub I, LLC dba Internet Brands