Run Program/Open Document Task Not Working

Discuss RoboTask here
elwayfan446
Posts: 46
Joined: Tue Mar 28, 2017 3:05 pm

Run Program/Open Document Task Not Working

Post by elwayfan446 »

Hi, I am currently trying to run a .cmd file with a simply Run/Program task but it isn't working. The command windown just flashes and goes away. If I put a pause in the .cmd file, there is nothing there.... no errors or anything. The crazy thing is that I can call the same file with windows task scheduler and it works fine. Can you tell me why this isn't working?

I have attached screenshots of windows scheduler and robotask.
Windows Scheduler.png
Windows Scheduler.png (12.53 KiB) Viewed 32437 times
RoboTask.png
RoboTask.png (19.17 KiB) Viewed 32437 times
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Program/Open Document Task Not Working

Post by Oleg »

I tried the similar task. It works
the task is

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1680400764
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task280"
Hide=INTEGER|0
ID=INTEGER|-258379537
LogOnAsUser=INTEGER|1
Name=STRING|"Run ""Test cmd file with spaces.cmd ""..."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER

[Actions\Action1]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""Test cmd file with spaces.cmd"" """
Params=FOLDER

[Actions\Action1\Params]
ifnonzero=STRING|"0"
program=STRING|"""D:\Just test folder with spaces\Test cmd file with spaces.cmd"""
runas=STRING|"0"
wait=STRING|"0"
workdir=STRING|"""D:\Just test folder with spaces"""
CMD file is simple:

Code: Select all

pause
Maybe the problem is in the environment and the CMD file.
Windows Task Scheduler run the task under SYSTEM account
But when you try to run the CMD file from RoboTask application it starts the CMD file in your own user account

Try to run your CMD by double-click from windows explorer
Does it works?
Oleg Yershov
elwayfan446
Posts: 46
Joined: Tue Mar 28, 2017 3:05 pm

Re: Run Program/Open Document Task Not Working

Post by elwayfan446 »

Oleg, yes.. that was what was so confusing. When I click from explorer it works fine. Same with Windows Scheduler. I just can't get it to work with RoboTask.
elwayfan446
Posts: 46
Joined: Tue Mar 28, 2017 3:05 pm

Re: Run Program/Open Document Task Not Working

Post by elwayfan446 »

Hi Oleg, I am still having this issue. Like I mentioned, I am able to double click the file and run it just fine. I am not sure why using the user account over the system account matters. I do have admin privledges on my machine. Any other ideas?
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Program/Open Document Task Not Working

Post by Oleg »

... The command windown just flashes and goes away. ...
I think that your CMD has been started but fails for some reason.

Also you cat try to use the command line:
cmd.exe /c "your_CMD_lile_full_name.cmd"
Pay attention that you can use this command line in Run Command-Line Utility action.
This action allows to catch output stream to variable.


To redirect output to a file use the line
cmd.exe /c "your_CMD_lile_full_name.cmd" > output.txt

Maybe you can read some error messages in the output stream
Oleg Yershov
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Program/Open Document Task Not Working

Post by Oleg »

Also try to remove quotes from CMD name and folder name
This works on my computers but it is possible some specific environment on your computer
Oleg Yershov
elwayfan446
Posts: 46
Joined: Tue Mar 28, 2017 3:05 pm

Re: Run Program/Open Document Task Not Working

Post by elwayfan446 »

Oleg, I tried what I thought you meant but I don't think I am following. Is there any way you could provide an example?
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Program/Open Document Task Not Working

Post by Oleg »

Example with redirect output:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1680400764
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task280"
Hide=INTEGER|0
ID=INTEGER|-258379537
LogOnAsUser=INTEGER|1
Name=STRING|"Test cmd file with spaces (redirect output)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FOLDER_CHANGE"
Enabled=INTEGER|-1
Name=STRING|"Change Folder (D:\Just test folder with spaces)"
Params=FOLDER

[Actions\Action1\Params]
folder=STRING|"D:\Just test folder with spaces"

[Actions\Action2]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""cmd.exe /c ""Test cmd file with spaces.cmd"" > output.txt"""
Params=FOLDER

[Actions\Action2\Params]
ifnonzero=STRING|"0"
params=STRING|"/c{EOL}""Test cmd file with spaces.cmd"" > output.txt"
program=STRING|"cmd.exe"
runas=STRING|"0"
wait=STRING|"2"
workdir=STRING|"""D:\Just test folder with spaces"""

[Actions\Action3]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""output.txt """
Params=FOLDER

[Actions\Action3\Params]
ifnonzero=STRING|"0"
program=STRING|"output.txt"
runas=STRING|"0"
wait=STRING|"0"
Example with "Run Command-line utility":

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1680400764
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task290"
Hide=INTEGER|0
ID=INTEGER|-1161914820
LogOnAsUser=INTEGER|1
Name=STRING|"Test cmd file with spaces (commandline utility)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_FOLDER_CHANGE"
Enabled=INTEGER|-1
Name=STRING|"Change Folder (D:\Just test folder with spaces)"
Params=FOLDER

[Actions\Action1\Params]
folder=STRING|"D:\Just test folder with spaces"

[Actions\Action2]
ActionID=STRING|"A_MISC_RUNCONSOLEAPP"
Enabled=INTEGER|-1
Name=STRING|"Run command-line utility: cmd.exe /c ""Test cmd file with spaces.cmd"""
Params=FOLDER

[Actions\Action2\Params]
convertansi=STRING|"0"
ifnonzero=STRING|"0"
outputvar=STRING|"out"
params=STRING|"/c{EOL}""Test cmd file with spaces.cmd"""
program=STRING|"cmd.exe"
saveexitcode=STRING|"0"
saveoutput=STRING|"1"
workdir=STRING|"""D:\Just test folder with spaces"""

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{out}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"{out}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
elwayfan446
Posts: 46
Joined: Tue Mar 28, 2017 3:05 pm

Re: Run Program/Open Document Task Not Working

Post by elwayfan446 »

Unfortunately, I haven't dealt much directly with the files. I have only used the interface to set up tasks. Can you tell me what I would need to do with these? Where would I keep them? Do I just modify the strings in the script to direct to my files?
Oleg
Site Admin
Posts: 3010
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Run Program/Open Document Task Not Working

Post by Oleg »

Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
You can open the task in the task editor after importing and see parameters of each step
Oleg Yershov
Post Reply