I'm trying to execute a nodejs command from a vbscript/classic asp page. I'm starting with lessc (less compiler) but need to use other commands too.
nodejs is installed, and I installed lessc in the global namespace (e.g. npm install -g less
) I can (at the server cmd prompt) issue lessc and it works.
at the server command prompt, I can issue a command that executes lessc, such as:
lessc D:\webs\player\Layout\less\app.less > D:\webs\player\Layout\less\app.css
but when I execute it thusly inside vbscript:
dim path : path = "D:\webs\player\Layout\less\"
dim shell : shell = server.createobject("WScript.Shell")
dim errCode : errCode = shell.Run("lessc " & path & "\app.less > " & path & "\app.css", 0, true)
response.write errCode
then it does nothing. Substituting the command so that it runs CMD ahead of lessc goes one step forward: it creates a zero byte output file (app.css):
dim errCode : errCode = shell.Run("CMD /C lessc " & path & "\app.less > " & path & "\app.css", 0, true)
So it looks like it's not finding lessc
, even though it's defined in the path variable; ECHO %PATH%
at the servers command prompt shows the path where lessc is located. So I tried executing the full path to lessc and even that doesn't seem to work ( no errors, no output ):
dim errCode : errCode = shell.Run("CMD /C C:\Users\Administrator\AppData\Roaming\npm\lessc " & path & "\app.less > " & path & "\app.css", 0, true)
.. frustrated now .. I tried piping the output of lessc
itself to a file, and it outputs a zero byte file. So it's doing something, just not executing lessc.
call shell.Run("CMD /C C:\Users\Administrator\AppData\Roaming\npm\lessc > c:\temp\lessc.txt", 0, true)
Just how do you get path variables to work in a shell.run anyway? is there a better way to execute a nodejs command server side from in vbscript/classic asp? it's going to be one of those stupid little things I always forget when working with IIS, isn't it?