Results 1 to 2 of 2

Thread: New to JAVA please help

  1. #1
    Join Date
    Oct 2004

    New to JAVA please help

    I'm not sure if this is the forum but hopefully someone can reply to my problem. I am new to creating .cmd and .vbs files and have been teaching myself for the past 2 days and can't figure this one out.
    I want to launch a JAVA script within a .cmd file so I can add a printer on a remote workstation.
    Basically I have no idea on how to do this. I have found a script that I saved as a .vbs to add a printer on a local workstation but would like to amplify this so it works in this .cmd file.
    The code I have come up with is this, but it doesn't work:-
    @echo off
    echo Add Printer %2 on %1

    if {%1}=={} goto Syntax
    if {%2}=={} goto Syntax

    psexec \\%1 -i -d -s notepad

    Dim net
    Set net = CreateObject("WScript.Network")
    net.AddWindowsPrinterConnection "%2"

    Saveas \\%1\c$\temp\printer.vbs

    Launch \\%1\c$\temp\printer.vbs
    Del \\%1\c$\temp\printer.vbs

    echo Adds a printer on the target workstation
    echo Usage: Printer [Computername] [\\Server\Printer]

    This works up until psexec launches notepad on the remote workstation. Then I just get a errors. I know the saveas and the vbs code is wrong but you get the jist of what I want this to do.

    What I would like to know is how to add the Bold code to the notepad window that launched and then to save it on the workstation as a .vbs file, then launch it and then delete it. I think then I will be able to figure out the rest.

    Is this possible? Can I do this?
    Or is there another way?
    Any replies would be very helpfull...

  2. #2
    Join Date
    Dec 2002
    Calgary, Canada
    the reason your code does not work for Java is because its anything but Java, please post your question in an appropriate forum...(.NET may be?)


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center