?
Solved

IPCONFIG Command (almost the same as from Klainn)

Posted on 2006-05-24
22
Medium Priority
?
449 Views
Last Modified: 2013-12-18
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?
0
Comment
Question by:attila01
  • 8
  • 6
  • 5
  • +1
20 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 16751225
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
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16751247
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 16752290
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 !
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:marilyng
ID: 16752919
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.. :)
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16754691
This is the right URL, file name is Pccensus-new.zip:
ftp://ftp.boulder.ibm.com/software/lotus/pub/lotusweb/devtools/
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16756899
Yahoo!  Yup!  Again, depends on the needs here.  But that's it exactly, marko.
0
 

Author Comment

by:attila01
ID: 16759127
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])
0
 

Author Comment

by:attila01
ID: 16759163
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
0
 

Author Comment

by:attila01
ID: 16759181
marilyng,

You can send me the Code if I can adapt it to my Helpdesk database.
0
 
LVL 22

Accepted Solution

by:
mbonaci earned 120 total points
ID: 16759209
attila01,
did you check this link, you have the working solution there:
http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/43fa6f0fa606e4db85256b7d00751a8a?OpenDocument

Marko
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16759234
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
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16765224
Attila01,  Marko was kind enough to supply the links for you!
0
 

Author Comment

by:attila01
ID: 16767449
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

0
 
LVL 18

Expert Comment

by:marilyng
ID: 16772991
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
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16782691
I don't believe that "sleep 2" is working :))

Marko
0
 

Author Comment

by:attila01
ID: 16783649
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.
0
 

Author Comment

by:attila01
ID: 16783669
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.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 16783901
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
0
 
LVL 18

Assisted Solution

by:marilyng
marilyng earned 120 total points
ID: 16784077
This is not meant to replace Marko's code, it just does the shellandwait...

When you paste the  " _ " are  line  breaks, and the first line will be blank but the subsequent lines will be red. You basically have to tell developer that they're there.  They will paste into the declarations section.

To do this,  backspace so that the second line comes up to the first line:
Declare Function CreateProcessA Lib "kernel32" (Byval lpApplicationName As Long; Byval lpCommandLine As String; Byval _

Then add the "_"  + ENTER again.
Declare Function CreateProcessA Lib "kernel32" (Byval _
lpApplicationName As Long; Byval lpCommandLine As String; Byval _

The second line will turn black.  Then do this for the other lines.

Also, replace all the SEMI-COLONS with COMMAS.  (Sorry, didn't see that when I posted)
Sub ShellAndWait(Byval RunProg As String)

0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month17 days, 5 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question