Action commands are not working

I am new to action language. I am trying to create folder in c:\temp\test if not exists and copy files and exporting eventlogs.

folder is creating WEVTUtil command not executing but xcopy command is working. what am I missing here. same commands are working in command line

// create test folder if it doesn’t exist
if {not exists folder “c:\Temp\test”}
folder create "C:\Temp\test"
endif

dos WEVTUtil query-events Microsoft-Windows-WindowsUpdateClient/Operational /count:50 /rd:true /q:“Event[System[(EventID=40)]]” > c:\Temp\test\Eventlogs.log

dos xcopy “C:\Program Files\Tivoli\TSM\baclient*.log” “c:\Temp\test” /Y

Well … it is as the exec You are attempting to run miss of environment and/or dependencies the Windows user with which the agent is running ( by default the Local System Account ) cannot know by itself …

I presume the Event Viewer should track the attempt to run that exec and help You in troubleshooting …

Its very possible that your path is being turned into a “Program Files (x86)” directory by Windows as we are a 32 bit application. Check out https://developer.bigfix.com/action-script/reference/execution/action-uses-wow64-redirection.html

Hi Alan,

Thanks for the help. here is the code but still xcopy is not working. what wrong am I doing ?

waithidden cmd.exe /c mkdir c:\Temp\CEMLog

action uses wow64 redirection false
waithidden cmd.exe /C dos xcopy “C:\Program Files\Tivoli\TSM\baclient*.log” “c:\Temp\CEMLogs” /Y

waithidden cmd.exe /C dos WEVTUtil query-events Microsoft-Windows-WindowsUpdateClient/Operational /count:50 /rd:true /q:“Event[System[(EventID=40)]]” > c:\Temp\CEMLogs\Eventlogs.log

A few things …
You’re creating the directory “CEMLog” (no “s” at the end) and then copying to “CEMLogs”.

You should also not have a trailing backslash on the xcopy command for the target directory.

You should not mix the use of ‘dos’ commands with ‘waithidden’, so either use ‘dos xcopy’ or ‘waithidden cmd /c’, but not both.

You probably should not use the ‘dos’ family of commands, those are (I believe) deprecated in favor of ‘waithidden’.

And you may be encountering a problem with ‘waithidden’ and multiple quoted command-line parameters. I’ve had problems with that before. The easiest workaround is to create a batch file and execute it, so you don’t have to worry about the quoted parameters. It may be possible to rewrite the xcopy command as

waithidden "cmd /C xcopy "C:\Program Files\Tivoli\TSM\baclient*.log" "c:\Temp\CEMLogs\" /Y"

but I haven’t tried that. Generally I’d build a batch file out of it instead, like

action uses wow64 redirection false
delete __createfile
createfile until EOF_EOF_EOF
mkdir c:\Temp\CEMLogs
xcopy "C:\Program Files\Tivoli\TSM\baclient*.log" "c:\Temp\CEMLogs" /Y
WEVTUtil query-events Microsoft-Windows-WindowsUpdateClient/Operational /count:50 /rd:true /q:"Event[System[(EventID=40)]]" > c:\Temp\CEMLogs\Eventlogs.log
EOF_EOF_EOF

delete MyBatch.cmd
move __createfile MyBatch.cmd
waithidden cmd /c MyBatch.cmd

Hope this helps

Hi Jason,

Good day!

Thanks for the quick help. I have modified as per you guidance.

here is the working code

waithidden cmd.exe /c mkdir c:\Temp\CEMLogs

action uses wow64 redirection false
waithidden cmd.exe /C xcopy “C:\Program Files\Tivoli\TSM\baclient*.log” c:\Temp\CEMLogs\ /Y

waithidden cmd.exe /C WEVTUtil query-events Microsoft-Windows-WindowsUpdateClient/Operational /count:50 /rd:true /q:“Event[System[(EventID=40)]]” > c:\Temp\CEMLogs\Eventlogs.log

Thanks you.