Ivanus
18th November 2015, 14:58
Hi, I'm using a powershell script within a Job in Baan.
This script should "simple" copy files from another Windowsserver to my BaaN-Server and create a new file. When I start the script with powershell it's working fine.
As soon as I start the script in the Baan Job it seems that the "net use" command with credentials is not working anymore and so the whole script fails.
Any ideas ?
Thanks
benito
18th November 2015, 16:30
1) i haven't done powershell script in a job but is your job user a user that has legit credentials in that server? have you tried logging in as the job user and run the script?
2) any reason why you didn't use simple windows bat script? baan script? ftp?
Ivanus
18th November 2015, 16:53
Hi,
I was using a simple "cmd" script before but with the same results.
cmd by itself is running - in the job the "net use" is not working anymore.
del /q D:\IT.TRANSFER\kw\*.TXT
net use T: "\\server\folder\" /user:abc 1234
copy \\server\folder\*.TXT D:\IT.TRANSFER\kw\
copy /a D:\IT.TRANSFER\kw\00*.TXT D:\IT.TRANSFER\kw\kw.txt
net use T: /delete
Mayby any other ideas how I can copy files from my BaaN Windows Server to another Windows Server with credetials ?
bhushanchanda
18th November 2015, 17:49
Hi,
Are you getting any error message? You can get the output of the bat file using run.prog() Baan command and see what is the issue. Probably it sounds like this has something to do with permissions.
I have used xcopy and robocopy and both worked fine.
Here are some links to guide you -
Link 1 (http://superuser.com/questions/197290/how-can-i-copy-a-file-from-my-machine-to-another-machine-from-command-line)
Link 2 (http://serverfault.com/questions/4639/what-is-the-windows-command-line-command-to-copy-files)
Also, for your problem you might also check this (http://superuser.com/questions/690287/command-prompt-in-administrator-mode-doesnt-see-mapped-drives).
I remember, I had a command where I needed elevated mode/admin rights to run. I ended up creating a Scheduled Task to run the program as Admin and then created a bat file to run the schedule task.
Ivanus
20th November 2015, 13:56
I really become desperate with this issue.
I'm not able to run this in a job.
I'm starting a session with following input:
INPUT ->> /c D:\SCRIPT\blabla.cmd
Part of my session
---------------------------------------------------------------------------------------
choice.cont.process:
on.choice:
if not isspace(script.command) then
if POS(script.command,"ps1") <> 0 then
err = run.prog("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe",
strip$(shiftl$(shiftr$(script.command))),RP_NOWAIT)
else
err = run.prog("C:\Windows\System32\cmd.exe",
strip$(shiftl$(shiftr$(script.command))),RP_NOWAIT)
endif
endif
---------------------------------------------------------------------------------------
blabla.cmd contains the following:
---------------------------------------------------------------------------------------
del /q D:\IT.TRANSFER\*.TXT
copy T:\z_B_tst\00*.TXT D:\IT.TRANSFER\
copy /a D:\IT.TRANSFER\00*.TXT D:\IT.TRANSFER\kw.txt
---------------------------------------------------------------------------------------
D:\ is the BaaN-Server (Windows)
T:\ is another Windows Server
the del command is working but not the copy
When I start the script in a cmd Window or in powershell it's working
Please help !!
bhushanchanda
20th November 2015, 14:37
Hi,
Does the Baan user has access to the directory of the other server? Because, del is running for local files while copy is running for remote files.
Can you try using copy command for local file just to check if its working? If yes, then the only problem here is with permissions.
Ivanus
20th November 2015, 14:52
Internal copy is working.
T:\ drive is mapped on the Baan Server with a usere who has rights.
Which user is Baan using? The user I'm logged on with or the Jobuser?
Thanks
bhushanchanda
20th November 2015, 15:04
It depends on the kind of mapping you have in your environment. Can you try some other command like dir command or mkdir command?
run.prog("cmd.exe","cmd /c mkdir" & dir.name,RP_WAIT)
Also, you can try the inbuilt tools function in case if you want to move the files.
Syntax:
function long file.mv.across.hosts (const string source, const string target)
Description
This moves a specified source file to the location specified in the target argument. The file can be either local or remote. Source and target can be on different hosts.
Arguments
const string source Source file.
const string target Target file.
Return values
1 Success.
<0 Error.