Link to home
Start Free TrialLog in
Avatar of attila01
attila01

asked on

IPCONFIG Command (almost the same as from Klainn)

I've already asked a similar question here some weeks ago but it seems that the answer you gave Klainn is the best for me.

Unlike Klainn I want to attach the txt file into a Field.

The txt file is created under the C drive --OK
A txt file is attached into the Field --OK
When I open the txt file under C, it shows the settings --OK

But when I open it on the Form the txt file is empty!
The attached file is called INFORMATION . TXT but when I open it shows a name like  ~0719266.TXT and is empty as I said already.
Here is the code:

@Command([Execute]; "cmd"; "/C IPCONFIG.EXE /ALL > C:\\IPINFORMATION.TXT");
@PostedCommand([EditGotoField];"txt");
@PostedCommand( [EditInsertFileAttachment] ; "C:\\IPINFORMATION.TXT" );
@Command([ViewRefreshFields])

Why is the attached file empty?
Avatar of mbonaci
mbonaci
Flag of Croatia image

Hi attila01,
I think you need something like this (Win API function ShellAndWait):

http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/92d71ea9b0014c7285256964005ab2dc?OpenDocument

Hope this helps,
Marko
Avatar of SysExpert
Other option is to use a DOS name  in 8.3 format  ie InfoIP.txt ( up to 8 chars before the dot ).

I hope this helps !
Avatar of marilyng
marilyng

You know, I've always just done all of this in Lotus Script and sent the results off to a database, or some other collection.   Instead of trying to run IPCONFIG, why not run Windows Scripting to grab what you need programmatically?  If you need the code, let me know and I'll post a snippet.

Basically, I have a HELP Desk application that when users log onto it, it collects all their computer information, hard drives, system information, ipaddress, network address, etc.  So, I not only get the help request, I get the computer footprint.


But that's my thoughts.. :)
This is the right URL, file name is Pccensus-new.zip:
ftp://ftp.boulder.ibm.com/software/lotus/pub/lotusweb/devtools/
Yahoo!  Yup!  Again, depends on the needs here.  But that's it exactly, marko.
Avatar of attila01

ASKER

When I  use a DOS name  in 8.3 format, the result is the same. (the txt file will be created under C: with the setting info but the attachment on the Form is empty).

I can attach an already created file (with long name) into the Form with this:

@PostedCommand([EditGotoField];"txt");
@PostedCommand( [EditInsertFileAttachment] ; "C:\\IPINFORMATION.TXT" );
@Command([ViewRefreshFields])

I think there's something wrong with my code, please have a look at it:

@Command([Execute]; "cmd"; "/C IPCONFIG.EXE /ALL > C:\\IPINFORMATION.TXT");
@PostedCommand([EditGotoField];"txt");
@PostedCommand( [EditInsertFileAttachment] ; "C:\\IPINFORMATION.TXT" );
@Command([ViewRefreshFields])
When I use the below Code a new memo will be opened and a file is attached and the file isn't empty.

@Command([Execute]; "cmd"; "/C IPCONFIG.EXE /ALL > C:\\IPINFORMATION.TXT");
@Command([Compose]; @MailDbName; "Memo");
@PostedCommand( [EditInsertFileAttachment] ; "C:\\IPINFORMATION.TXT" );

I can attach a file into a memo but not into a Field.

Isn't it that when the file is attached to the Form the file is not fully created?

Sorry, I didn't have time to check the links till now
marilyng,

You can send me the Code if I can adapt it to my Helpdesk database.
ASKER CERTIFIED SOLUTION
Avatar of mbonaci
mbonaci
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
attila01,
maybe try to use this before going to script:
@Command([Execute]; "cmd"; "/C IPCONFIG.EXE /ALL > C:\\IPINFORMATION.TXT");
@Command([Compose]; @MailDbName; "Memo");
@Command( [ToolsRunMacro] ; "SleepALittle" )
@PostedCommand( [EditInsertFileAttachment] ; "C:\\IPINFORMATION.TXT" );

And the "SleepALittle" LS agent would be simply this (to wait for 2 seconds):
Sleep 2

Hope this helps,
Marko
Attila01,  Marko was kind enough to supply the links for you!
Thanks, it works with the "Sleep 2"

I tried with the link  
http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/
43fa6f0fa606e4db85256b7d00751a8a?OpenDocument
  as well but got an error message when try to save, in the next line:

ShellAndWait filename & " " & addr

The error message is following:

Not a sub or function name SHELLANDWAIT

ShellandWait is a function that has contained in it another function CreateProcessA

If the  shellandWait is not in your code, then you will get the error message.  

RE: Shell a 32-bit process and Wait till Finish...
Posted by Charles M Russo on 24.Sep.00 at 12:30 PM using a Web browser
Category: Domino Designer -- LotusScriptRelease: 5.0.2Platform: Windows NT
http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/92d71ea9b0014c7285256964005ab2dc?OpenDocument

Here is the complete reference:

Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

Declare Function WaitForSingleObject Lib "kernel32" (Byval _
hHandle As Long; Byval dwMilliseconds As Long) As Long

Declare Function CreateProcessA Lib "kernel32" (Byval _
lpApplicationName As Long; Byval lpCommandLine As String; Byval _
lpProcessAttributes As Long; Byval lpThreadAttributes As Long; _
Byval bInheritHandles As Long; Byval dwCreationFlags As Long; _
Byval lpEnvironment As Long; Byval lpCurrentDirectory As Long; _
lpStartupInfo As STARTUPINFO; lpProcessInformation As _
PROCESS_INFORMATION) As Long

Declare Function CloseHandle Lib "kernel32" (Byval _
hObject As Long) As Long

Const NORMAL_PRIORITY_CLASS = &H20&
Const INFINITE = -1&
------------------------------
2. a subroutine

Sub ShellAndWait(Byval RunProg As String)

Dim RetVal As Long
Dim proc As PROCESS_INFORMATION
Dim StartInf As STARTUPINFO
StartInf.cb = Len(StartInf)
'Execute the given path
RetVal = CreateProcessA(0&; RunProg; 0&; 0&; 1&; _
NORMAL_PRIORITY_CLASS; 0&; 0&; StartInf; proc)

'Disable this app until the shelled one is done
RetVal = WaitForSingleObject(proc.hProcess; INFINITE)
RetVal = CloseHandle(proc.hProcess)

End Sub

------------------
3. execution using a button.

Sub Click(Source As Button)
'When you're ready to shell out to the separate process; run this code:
ShellAndWait "notepad.exe"
'The next line will not execute until Notepad has closed.
Msgbox "Notepad has been closed."
End Sub
I don't believe that "sleep 2" is working :))

Marko
Where should I paste all this Code?

When I select the button and Lotus script then the Declaration and Click part is OK but I get lots of error message in Option and ShellAndWait part.
I must admit that the above Code is not easy to understand for me but if I've noting to do just paste it, then I should be able to manage it.

I not even know if the above Code should replace the Formula with the Agent "SleepALittle" or the two should be function together.
attila01,
I thought you settled with sleep agent and that @Formula?

If not:
just paste the code (all except the 3rd section) Maryling posted in Globals - Declarations of the form where your button (or action) is.
Only the third part of the code (3. execution using a button) is to replace your button's Click event (be sure to choose LotusScript in the second drop down field - where the "Client" is in the first one).

Hope this helps,
Marko
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial