# psexec error



## paultown (Oct 29, 2004)

I have created the following batch file that automatically creates a file call printer.vbs on a remote system, but when I try to get psexec to lauch the file I get an error "The system cannot find the file specified."
The file is defidently there and can't understand why it can't be launched.
I tried a variation by getting the batch file to create another batch file that calls for printer.vbs but got the same error.
The code is as follows:-

@echo off
cls
echo Add Printer %2 on %1
echo ____________________________________________
echo.

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

CALL
>>\\%1\c$\apps\nai\printer.vbs ECHO '-------------------------------------------
>>\\%1\c$\apps\nai\printer.vbs ECHO ' Printer Install for network printer:
>>\\%1\c$\apps\nai\printer.vbs ECHO ' %2 
>>\\%1\c$\apps\nai\printer.vbs ECHO '-------------------------------------------
>>\\%1\c$\apps\nai\printer.vbs ECHO Dim net
>>\\%1\c$\apps\nai\printer.vbs ECHO Set net = CreateObject("WScript.Network")
>>\\%1\c$\apps\nai\printer.vbs ECHO net.AddWindowsPrinterConnection "%2"
>>\\%1\c$\apps\nai\printer.vbs ECHO '-------------------------------------------

Call Wait 10
psexec \\%1 -c c:\apps\nai\printer.vbs

echo Printer %2 has been successfully added on %1.

Goto End

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

:End
pause

I added the call wait 10 line just to make sure the file did get created before psexec tried to launch it, but still failed.

Anyone have any thoughts as to why psexec can't find the file?


----------



## paultown (Oct 29, 2004)

I have update the psexec line to state the following:-
*psexec \\%1 cscript.exe printer.vbs*
This works when I launch it on a local workstation just not remotely I get the following error in the command prompt:-

PsExec v1.42 - execute processes remotely
Copyright (C) 2001-2003 Mark Russinovich
www.sysinternals.com

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\WINNT\system32\printer.vbs(8, 1) (null): The system cannot find the file spec
ified.

cscript.exe exited on wau34420180 with error code 0.

Any ideas?


----------



## Squashman (Apr 4, 2003)

Try running it remotely on the machine you know it runs locally on. It is not a psexec error. What operating system did you run it locally on? Which OS are your trying to run it remotely on?

I think it might be confused on where cscript.exe is.


----------



## paultown (Oct 29, 2004)

Thanks for the quick reply LwdSquashman!
All workstations on the network are running NT4. 
I tried running on a different workstation same thing, it worked when I used the local workstation name just not when I try to execute it on a remote workstation. I also tried lauching it on the workstation I originally worte it on, still no go 
I am pretty new to scripting and batch files and am really stumpted on this one...
Anymore ideas?


----------



## Squashman (Apr 4, 2003)

Are the Visual Basic Runtime files installed on all the machines as well as Windows Script Host 5.6.

Take a look at this KB article as well.
http://support.microsoft.com/kb/q248121/


----------



## paultown (Oct 29, 2004)

Yes, all Visual Basic Runtime files are installed, we use alot of other scripts for e.g login, server resets, software downloads, ect...


----------

