
running DOS commands on NT using WSH
Quote:
> I have updated the FAQ to include cmd.exe for NT systems.
> Regards,
> Ian
> WSH FAQ http://wsh.glazier.co.nz
I believe it should just be changed to %COMSPEC%. That works for ALL MS
OS's, whether the command processor is stored in a folder named on the
path or not. Specifically, ...
iReturn = WshShell.Run("%COMSPEC%/K Dir c:\Windows\system32", 1, TRUE)
In this application, the %Comspec% variable is expanded on use (as would
%systemdir% in place of the literal C:\Windows\system32).
BTW, the /K means that the secondary process will not end until the user
types EXIT <Enter> while the focus is in the console window. Unless
this is the desired operation, the /C should be used instead.
Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/
Quote:
> > What that error means is that your %path% is bad.
> > In NT, you should use cmd.exe.:
> > iReturn = WshShell.Run("cmd.exe /k Dir c:\Windows\system32", 1, TRUE)
> > If it's important to not have the NT command extensions available in the
> > prompt, do:
> > iReturn = WshShell.Run("cmd.exe /y /k Dir c:\Windows\system32", 1, TRUE)
> > Do 'cmd /?' at a command prompt for more information.
> > > Hello all!
> > > I am trying to run a directory call from within a VBScript, and I tried
> > the
> > > following:
> > --------------------------------------------------------------------------
> > --
> > > ---------------------------------------
> > > set WshShell = wscript.createObject("Wscript.Shell")
> > > wscript.echo "starting"
> > > iReturn = WshShell.Run("command.com /K Dir c:\Windows\system32", 1,
> TRUE)
> > > wscript.echo "Hello"
> > --------------------------------------------------------------------------
> > --
> > > ----------------------------------------
> > > I got this script from Ian Morrish's site, but I keep getting the
> > following
> > > error:
> > > Invalid switch
> > > Specified COMMAND search directory bad
> > > Too many parameters
> > > Microsoft(R) Windows NT DOS
> > > (C)Copyright Microsoft Corp 1990-1996.
> > > F>
> > > Any suggestions?