Shell without confirmation-request of Navision 4.00

kriki
Member, Moderator Posts: 9,121
This function can be used instead of the SHELL-command that triggers the confirmation-request of Navision 4.00.
One remark:if you put "IblnWaitForEndOfCommand" to TRUE, the Navision-code waits for a return-value, but very strange is that it does NOT block the userinterface!
Local Variables:
The function:
One remark:if you put "IblnWaitForEndOfCommand" to TRUE, the Navision-code waits for a return-value, but very strange is that it does NOT block the userinterface!
Local Variables:
Name DataType Subtype Length Laut Automation 'Windows Script Host Object Model'.WshShell Lint Integer
The function:
DosShell(ItxtCommand : Text[1024];IintWindowStyle : Integer;IblnWaitForEndOfCommand : Boolean) OintReturnValue : Integer // DosShell //*** 109 // Works like SHELL and HYPERLINK of Navision but without the annoying confirmation-request of Navision 4.00 // (this function uses automation 'Windows Script Host Object Model'.WshShell) // PARAMETERS: // ItxtCommand : command + parameters for the SHELL // IintWindowStyle : Type of window for command // 0:Hides the window and activates another window. (=Doesn't even show a window, to kill the doscommand, // you have to do it with taskmanager=>Processes) // 1:Activates and displays a window. If the window is minimized or maximized, the system restores // it to its original size and position. An application should specify this flag when displaying // the window for the first time. (=shows the window as normal window) // 2:Activates the window and displays it as a minimized window. (=shows as minimized) // 3:Activates the window and displays it as a maximized window. (=shows as maximized) // 4:Displays a window in its most recent size and position. The active window remains active. // 5:Activates the window and displays it in its current size and position. // 6:Minimizes the specified window and activates the next top-level window in the Z order. // 7:Displays the window as a minimized window. The active window remains active. // 8:Displays the window in its current state. The active window remains active. // 9:Activates and displays the window. If the window is minimized or maximized, the system // restores it to its original size and position. An application should specify this flag // when restoring a minimized window. // 10:Sets the show-state based on the state of the program that started the application. // IblnWaitForEndOfCommand : TRUE : wait for the command to finish (and use the RETURN-VALUE) // FALSE: Launch the command and return (RETURN-VALUE will be 0) // RETURN-VALUE : SHELL-command RETURN-VALUE CREATE(Laut); OintReturnValue := Laut.Run(ItxtCommand,IintWindowStyle,IblnWaitForEndOfCommand); CLEAR(Laut);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
0
Comments
-
Nice, but When you need the result you can use execute
... WSHExec := WSHShell.Exec(Command); WSHTextStream := WSHExec.StdOut; WHILE NOT WSHTextStream.AtEndOfStream DO BEGIN message(WSHTextStream.ReadLine()); END;
RegardsDo you make it right, it works too!0 -
Hi Kriki,
Can you please let me know from where I will call this function?
Regards
Mini0 -
Hi Mini,
you can call this from every where in Navision. But this function is not a Navision function, it's customized.
So, you must create this "example function" self. Also you need the "Windows Scription Host" as Variable (if you need more infos about these theme, search the forum for Windows Scripting Host or WSH)
To understand this example, create, only for this example, a blank form with a button.
In the form you create the Kriki's function with the needed WSH variable. From your button you call the function likeRetournValueAsInteger := DosShell('notepad.exe',1,true);
Now, Notepad is opend (as example)
RegardsDo you make it right, it works too!0 -
It doesn't seem to work if the executable is located on folder with spaces on its name, such "C:\Documents and Settings\me\program.exe"
Any ideas, please?0 -
In the dos-prompt you can find the short names with "dir /x", maybe that will work?0
-
try this : dosshell('"C:\Documents and Settings\me\program.exe"');Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
hello, I have problem with windows scripting host
I am trying to send some text file with label to printer connected via USB port (USB is mapped to LPT 1 in windows)
I am using this code:
IF ISCLEAR(autWinScriptHost) THEN
CREATE(autWinScriptHost);
txtCommand := 'copy /B ' + txtFilename+ ' LPT1';
autWinScriptHost.Run(txtCommand);
where txtfilename is d:\Navision\ProTeam\geis\PDL1208283.txt
attached error appears
there are no spaces in file path.
Please, can you tell me, what can be wrong? Thanks in advance.Martin Bokůvka, AxiomProvis0 -
Does it work when you run it directly from DOS?
Which version of NAV are you using?Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
NAV 2009 R2, classic
from commandline it works (I copied value of txtcommand from debugger and inserted it to commandline)Martin Bokůvka, AxiomProvis0 -
Found it:
Copy is not an executable but is part of the cmd.exe. So you need to run that for copying the file:
"cmd.exe /C copy ...."Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Awesome, that worked like a charm.
Thank you very much.Martin Bokůvka, AxiomProvis0 -
Hi, I know the topic is quite old, but I have an answer.
I use this to do ftp transfers with an ftp commandline tool. works pretty good.
I use the "IblnWaitForEndOfCommand = true" Option. And mostly the returnvalue is 0, which is OK.
But sometimes I get "3" as returnvalue, and I don't know what that means, and I can not find information about the different returnvalues0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions