Issue commands in an MS Command Prompt Window

I have a situation where I need to open an MS Command Prompt window, issue some ldap commands and then close the MS Command Prompt window from a scheduled LotusScript agent.

I can get the MS Command Prompt window to open:

pgmtorun = “cmd.exe”

temp = "C:\WINNT\system32" + pgmtorun

taskId% = Shell(temp, 1)

but how can I get the cmdtorun value (below) to be entered in the MS Command Prompt window, executed and then close the MS Command Prompt window?

cmdtorun = “ldapsearch -h 1.2.3.4 -b o=ibm,c=us -L uid=xxxxxxxx@us.ibm.com”

I’ve been looking at SendKeys and have seen some information on “user32.dll”. Does anyone have any suggestions on a way to do this?

Any help would be greatly appreciated. Thanks.

Subject: Issue commands in an MS Command Prompt Window

Why don’t you just run this program, not the command shell?

ldapsearch -h 1.2.3.4 -b o=ibm,c=us -L uid=xxxxxxxx@us.ibm.com

+Josh+

Subject: RE: Issue commands in an MS Command Prompt Window

Just shell to the command you want to run. If it’s an MSDOS program it’ll open its own command window.If there are multiple commands, you can write them into a .bat file and then shell out to the .bat.

Subject: Issue commands in an MS Command Prompt Window

Have you tried using the /c option in CMD i.e.

pgmtorun = “cmd.exe”

cmdLine = " ldapsearch -h 1.2.3.4 -b o=ibm,c=us -L uid=xxxxxxxx@us.ibm.com"

options = " /c"

temp = "C:\WINNT\system32" + pgmtorun + options + cmdLine

taskId% = Shell(temp, 1)

You may need to play with quotes in the cmdLine so that cmd identifies the switches as belonging to ldapsearch and not the cmd.

HTH - Rufus.