none
PowerShell run cmd command RRS feed

  • General discussion

  • Hello,

    I am very new to PowerShell scripting.

    Suddenly we want to move our code from VB script to PS, and i don't have much idea how to wrote this statement in PS.

    wshShell.Run(myCommand,0,false)

    Requirement: myCommand is IBM bat command (ibmdisrv) and its arguments, and want to run in background (So if I close PS screen or log off the server, still command run as a process).

    Thanks in advance.

    • Changed type Bill_Stewart Thursday, January 8, 2015 5:49 PM
    • Moved by Bill_Stewart Thursday, January 8, 2015 5:51 PM This is not support forum for third party software
    Friday, November 28, 2014 2:25 PM

All replies

  • PowerShell is a shell. One of the main purposes of a shell is to let you run commands.

    To run a command, just type it in and press Enter.

    If the command is in a script, just enter the command as a line in the script, and run the script.


    -- Bill Stewart [Bill_Stewart]

    Friday, November 28, 2014 4:01 PM
  • To run unattended run it under the scheduler service.


    ¯\_(ツ)_/¯

    Friday, November 28, 2014 4:32 PM
  • Hello,

    I am very new to PowerShell scripting.

    Suddenly we want to move our code from VB script to PS, and i don't have much idea how to wrote this statement in PS.

    wshShell.Run(myCommand,0,false)

    Requirement: myCommand is IBM bat command (ibmdisrv) and its arguments, and want to run in background (So if I close PS screen or log off the server, still command run as a process).

    Thanks in advance.

    Keep your VBScript or use this batch file to run IBM.bat in a separate process:

    @echo off
    start "" ibm.bat

    Friday, November 28, 2014 8:11 PM
  • Thanks For you response, 

    Still not getting many things, I have tried Start-Job but not working with me, By hook and crook my command working but it is not going to background or silent, always popup cmd promt.

    Here it is VB script

    ---------------------

    Set wshShell = WScript.CreateObject("WSCript.shell")
    var strCommand = "cmd.exe /K """"" & IDI_HOME & "\ibmdisrv"" -c""" & IDI_CONFIG_DIR & "\" & IDI_CONFIG_FILE & """ -r""" & IDI_ASSEMBLYLINES & """"""
    ' -c for config file and -r for assemlyLine flow
    cmdResponse = wshShell.Run(strCommand,0,false)

    Now want to PS (I tried but not worked)

    ------------

    $commandLine = '& "$TDI_INSTALL_HOME\ibmdisrv" -c "$TDI_CONFIG_FILE" -r "$TDI_ASSEMBLYLINE"';
    Start-Job -ScriptBlock {Invoke-Expression -Command:$commandLine}}


    Thanks

    Monday, December 1, 2014 3:34 PM
  • You will have to contact IBM for that.

    ¯\_(ツ)_/¯

    Monday, December 1, 2014 3:37 PM
  • have you tried it with "start-Process"??

    Start-Process $commandLine -WindowStyle Hidden


    Tuesday, December 2, 2014 10:25 AM