Announcement

Collapse
No announcement yet.

WScript.Shell %COMSPEC% HELP

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WScript.Shell %COMSPEC% HELP

    objShell.Run("%COMSPEC% /k cd /D d:")

    ' & chr(13)_
    '& "cd userRedirect" & chr(13)_
    '& "CACLS " & folder.name & "/T /E /C /P " & folder.name & ":c"

    '#################################
    'ATTEMPTING TO RUN THESE COMMANDS
    'cd /D d:
    'cd userRedirect
    'cacls %username% /t /e /c /p %username%:c
    '#################################

    How can I run these commands in the shell? I'm only able to run one at a time and they follow on from weach other so they need to be in the same command.com window

    thanks

  • #2
    Re: WScript.Shell %COMSPEC% HELP

    If you want to input multiple command lines as a stream, then use the StdIn Property of the objShell.Exec method (instead of objShell.Run method).
    http://forums.petri.com/showpost.php...81&postcount=3


    The objShell.Run launches the command-line like you would run the command via the Start | Run bar. However you are able to run multiple commands from there, if you join them by Ampersands,
    Example:
    cmd /c cd /D d: & cd "userRedirect" & cacls.exe %username% /t /e /c /p %username%:c
    Or better:
    cmd /c pushd "d:\userRedirect" & cacls.exe %username% /t /e /c /p %username%:c & popd
    Or simply
    cacls.exe "d:\userRedirect\%username%" /t /e /c /p %username%:c

    Code:
    rtrncd = objShell.Run("%COMSPEC% /c pushd ""d:\userRedirect"" & cacls %username% /t /e /c /p %username%:c & popd")
    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X