I wanted to track any changes in NAV done by a user using the login ID and terminal IP at the time of changes.
When i open RTC, i get an error that ENVIRON is absolute thus RTC never opens as the error keeps popping up.
Below is the code used in CU1
IF ISCLEAR(WindowShell) THEN BEGIN
CREATE(WindowShell);
WindowShell.CurrentDirectory(ENVIRON('windir') + '\system32\');
txtCommand := 'ipconfig';
WSHExec := WindowShell.Exec(txtCommand);
WSHTextStream := WSHExec.StdOut;
i := 0;
WHILE (NOT WSHTextStream.AtEndOfStream) AND (i < 8) DO BEGIN
txtMsg := WSHTextStream.ReadLine();
i += 1;
END;
IF GUIALLOWED THEN
UserSetup."User ID" := USERID;
UserSetup."IP Address" := COPYSTR(txtMsg,45);
recRef.GETTABLE(UserSetup);
UserSetup."IP Address" := '';
xrecref.GETTABLE(UserSetup);
ChangeLogMgt.LogModification(recRef,xrecref);
END;
Globals
Name Subtype DataType Length
WindowShell 'Windows Script Host Object Model'.WshShell Automation
WSHExec 'Windows Script Host Object Model'.WshExec Automation
WSHTextStream 'Windows Script Host Object Model'.TextStream Automation
Is there any other way of achieving the same but ensuring RTC is not affected
0
Comments
If yes then use
IF ISSERVICETIER then
exit;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I was a way of achieving this through RTC
em, you mean "terminal" is local machine, I just misunderstood you. Anyway, just use Windows Script Host Object Model to get local machine IP. I think you don't need to specify path for ipconfig, as WSH.run should be able to run ipconfig from any path.
Else you will receive the ip from the server
|To-Increase|
I used that in the variables as above.
Could you suggest a modification on my code to point me in the correct path.. [-o<
Perhaps if you help me with how the code would look like? [-o<
A modification of mine above.... :-k
replace CREATE(WindowShell); with CREATE(WindowShell,False,True);
And if you went into the help and look at the description of create, you can figure out why false is false and true is true.
Next is the environ "problem".
Ask yourself if shell really needs to run under the systemdir to succesfully run ipconfig.cmd.
Disclaimer: if we tell you how to write that code we can't be sure you GET the code you've written. And codemonkeys are frowned upon.
|To-Increase|
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n